WordPress Category Sorting Function

<?php

function modify_query_for_categories( $query ) {
  if ( $query->is_category('categoryname_oder_ID')  ) {
    $query->set( 'orderby', 'title' ); // sort by title
    $query->set( 'order', 'ASC' ); // sort a-z
    $query->set( 'posts_per_page', '25' ); // show 25 entrys
  }
}

add_action( 'pre_get_posts', 'modify_query_for_categories' );

?>

Leave a Reply