Support » Theme: MyKnowledgeBase » Alphabetical Archives

  • Resolved MacMhìcheil


    Is there a way to list the posts alphabetically on the category archives? I know how to do it on the homepage, but would like the archives to match.

Viewing 3 replies - 1 through 3 (of 3 total)
  • Hi,
    You can try this in your theme’s functions.php file:

    function order_category_archives_by_title( $query ) {
      if ( is_category() && $query->is_main_query() ){ // is_category() can specify a category, if necessary
        $query->set( 'orderby', 'title' );
        $query->set( 'order', 'ASC' );
    add_action( 'pre_get_posts', 'order_category_archives_by_title' );

    It is advised to put all custom action hooks and filters inside your theme’s functions.php which makes your theme files clean.

    Thread Starter MacMhìcheil


    That did it, many thanks for your help.

    You are welcome. Glad that helped you!

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Alphabetical Archives’ is closed to new replies.