Alphabetically Order Category Posts

Viewing 2 posts - 1 through 2 (of 2 total)
  • #21386
    garyjudge
    Participant

    Hi, I’ve been trying in vein to re-organise posts so that they appear in alphabetical order. Most of my posts in the specified category are arranged alphabetically, but some are out of order: http://www.tractor-dealers.net/category/tractors/

    I’ve modified the functions.php to include:

    
    if( $query->is_category( pinboard_get_option( 'TRACTORS' ) ) ) {
     $query->set( 'orderby', 'title' );
     $query->set( 'order', 'ASC' );
    }
    
    

    Can anyone give an explanation why not all posts are being rendered alphabetically? Thanks

    • This topic was modified 9 years, 5 months ago by garyjudge.
    #21411
    Daniel Tara
    Keymaster

    The is_category() function is not available in the pre_get_posts hook. You can use this code instead:

    if( isset( get_query_var( 'cat' ) ) && 38 == get_query_var( 'cat' ) )

    Replace 38 with the ID of your tractors category.

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.