• Resolved hktvb2001

    (@hktvb2001)


    Hi,

    I have add this code to my archive.php to order all posts by name:

    <?php $posts = query_posts($query_string . ‘&orderby=title&order=asc&posts_per_page=-1’); if (have_posts()) : ?>

    Well, it works! But I have created a category which I called “Site News”, and in that category, I have added the news on my site, but when I check that cat, all recent post has been order by name, which I don’t want. I want all other cat, except the Site News, to be order by name. I want the cat of “Site News” to be order by date..

    What should I do? I have searched and searched, but I can’t find the solution..

    Please help!

Viewing 2 replies - 1 through 2 (of 2 total)
  • Try this:

    <?php
    if(is_category('Site News')) {
    $orderby = 'post_date';
    $order = 'desc';
    } else {
    $orderby = 'title';
    $order = 'asc';
    }
    $posts = query_posts($query_string . '&orderby=' . $orderby . '&order=' . $order . '&posts_per_page=-1'); if (have_posts()) : ?>

    More info on conditional tags like is_category():

    https://codex.www.ads-software.com/Conditional_Tags

    Thread Starter hktvb2001

    (@hktvb2001)

    Sorry, I am late to reply to this post.. But thanks for your HELP!! IT’s work.. Yahoo! I am so glad.. he he he he.. la la la la..

    Thanks again!!! ??

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Problem with sorting post in cat..’ is closed to new replies.