Forums

Customizing a category (10 posts)

  1. brestolo
    Member
    Posted 1 year ago #

    hello,
    i need to customize just a category: some article should appear before than others but just for that category. Could you help me?

  2. alchymyth
    The Sweeper
    Posted 1 year ago #

    http://codex.wordpress.org/Category_Templates

    create a category template and make the edits in there.

  3. brestolo
    Member
    Posted 1 year ago #

    thanks for replaying, but i have some more questions:

    Because i have not a category file but i have the archive.php I have understood that i have to copy the archive.php and rename it in archive-2.php right?

    Wich code i have to add in archive.php to call the archive-2.php

    I want my category (called archive-2.php) make it in reverse chronological order (from the oldest to the newest one articles) but how to do this?

    How make the the "archive-2.php" corresponds to the category i desire?

    thank you

  4. brestolo
    Member
    Posted 1 year ago #

    hello,
    could someone help me??

  5. alchymyth
    The Sweeper
    Posted 1 year ago #

    a:
    don't call the file archive-2.php;
    call it category-my-desire.php - where my-desire is the category slug of your desired category.

    to reverse the order, add a line with query_posts() before the beginning of the loop:

    <?php global $query_string; query_posts($query_string . '&orderby=date&order=ASC'); ?>

    http://codex.wordpress.org/Function_Reference/query_posts#Usage_Note
    http://codex.wordpress.org/Function_Reference/WP_Query#Order_.26_Orderby_Parameters

  6. brestolo
    Member
    Posted 1 year ago #

    thank you alchymyth,

    it seems i solved...
    thank you a lot

  7. brestolo
    Member
    Posted 1 year ago #

    hi alchymyth or everybody,
    my customer is quite exigent..now he asks me if i could put some articles at the top of the category and remain there, could you help me again?

    thank you

  8. alchymyth
    The Sweeper
    Posted 1 year ago #

    put some articles at the top of the category

    this might need a clearer definition of 'some';

    however, this question is so different from your existing topic, you might want to start a new thread to get more attention.

  9. brestolo
    Member
    Posted 1 year ago #

    he wants 4 articles of that category at the top, before the others articles that should continue to their ASC order..

  10. alchymyth
    The Sweeper
    Posted 1 year ago #

    is this just for the special category template?
    how is he going to set the names or IDs of these four posts?

    assuming, for instance, if you have the post IDs (as a comma separated list, or in an array), you can simply make a foreach loop with get_posts() using the 'include' parameter before the main loop;
    http://codex.wordpress.org/Template_Tags/get_posts
    then, before the main loop begins, you could include a query to exclude these posts from whatever comes;
    for instance using the 'post__not_in' paramter with an array of the post IDs.
    http://codex.wordpress.org/Function_Reference/query_posts
    http://codex.wordpress.org/Function_Reference/WP_Query#Post_.26_Page_Parameters

    how i would structure it:
    http://pastebin.com/r4a8Fuiv

    (not tested, not checked for errors)

Topic Closed

This topic has been closed to new replies.

About this Topic