Set Post Order for Category pages?

Viewing 3 posts - 1 through 3 (of 3 total)
  • #14491
    luckymike
    Participant

    I’m trying to set the category pages to sort by title in ascending order. I’ve tried adding:

    if( $query->is_category() )
    $query->set( 'orderby' => 'title', 'order' => 'asc' )

    to pinboard_filter_query() but it breaks the page. Any suggestions?

    #14495
    Daniel Tara
    Keymaster

    Try 'orderby' => 'post_title'

    #14496
    luckymike
    Participant

    Thanks Daniel, that breaks as well. I installed a plugin for this feature which does the following:


    add_action('pre_get_posts','sort_categories_by_title');

    function sort_categories_by_title($x) {
    if(is_category()) {
    $x->query_vars['orderby'] = 'title';
    $x->query_vars['order'] = 'ASC';
    }
    }

    The same code fails in functions.php which suggests that something else is happening there that causes the failure.

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

Tagged: 

You must be logged in to reply to this topic.