Reverse Post Order for Single Category

Community Forums Forums Design Tips and Tricks Reverse Post Order for Single Category

This topic is: not resolved

Tagged: 

This topic contains 4 replies, has 3 voices, and was last updated by  JHSEsq 1 week, 4 days ago.

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #55465

    scallemang
    Participant
    Post count: 4

    Hi there,

    I’m looking for a way to print one of my categories in ascending chronological order while leaving all others descending.

    I’m only just starting out with PHP, so forgive any goofy errors. I found the following code somewhere online (the category in question is ID 8):

    function child_before_loop () {
    
    	global $query_string;
    
    	query_posts($query_string . "&order=ASC&orderby=date&cat=8");

    This worked fine for the one category – however, all other categories returned the “Sorry, no posts matched your criteria” message. Any suggestions?

    if (you === ‘helpful’) { me===’very grateful’; }

    Thanks a million.

    • This topic was modified 8 months, 2 weeks ago by  scallemang.
    • This topic was modified 8 months, 2 weeks ago by  scallemang.
    http://www.read2rap.com
    #55468

    David Chu
    Participant
    Post count: 1186

    Hi,
    A witty presentation. :-)

    I’ll shoot from the hip – depending on where you are in the template and/or loop, something like this should work, I think, to make it operative only on Category 8. The idea is to contain your line in an IF statement. Check me, as I didn’t test this:

    if ( is_category( '8' ) )  {
        query_posts($query_string . "&order=ASC&orderby=date&cat=8");
    }
    

    Cheers, Dave


    David Chu · Custom WordPress Developer – likes collaborating with Designers

    #55523

    scallemang
    Participant
    Post count: 4

    Got it working with your code. You rule!

    In case any other PHP-neophytes stumble upon this, here is the full code I used in the functions.php file (replace the category number with your own):

    add_action('genesis_before_loop', 'child_before_loop');
    
    function child_before_loop () {
    
    	global $query_string;
    	if ( is_category( '123' ) )  {
        query_posts($query_string . "&order=ASC&orderby=date&cat=123");
    	}
    }
    #55528

    David Chu
    Participant
    Post count: 1186

    Great!
    And I salute you for being willing to try PHP. You’ll go a lot further with Genesis than those who won’t!

    Dave


    David Chu · Custom WordPress Developer – likes collaborating with Designers

    #99872

    JHSEsq
    Member
    Post count: 3

    Using the Wintersong theme, that code did NOT work for me.
    And worse, I’ve tried at least three different plugins specifically designed to allow post category pages to display the posts in ascending, rather than descending, date order. None of those plugins work either! (Including Different Posts per Page by Max Blog Press.)
    So . . . I can only conclude there must be something in the Genesis or child theme code that is overriding the plugins and/or the code suggested above.
    Can anyone help?

    Thanks!

    • This reply was modified 1 week, 4 days ago by  JHSEsq.
    • This reply was modified 1 week, 4 days ago by  JHSEsq.
Viewing 5 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic.