Notice: These forums are now retired and closed. For active support, please Submit a Ticket or visit our official WordPress.org community pages.
Kadence Theme | Kadence Blocks | Starter Templates | WooCommerce Email Designer | Ascend | Virtue | Pinnacle

Ordering of all posts, even on category pages

Home / Forums / Virtue Theme / Ordering of all posts, even on category pages

This topic is: Resolved
[Resolved]
Posted in: Virtue Theme
May 22, 2015 at 4:45 am

Good Morning,

I am looking for an easy way to sort all blog posts alphabetically by title.

This works fine on the blog page but I have 3 category pages which still sort by post date.

I’m currently using this code in the functions.php file to do this:

function foo_modify_query_order( $query ) {
if ( $query->is_home() && $query->is_main_query() ) {
$query->set( 'orderby', 'title' );
$query->set( 'order', 'ASC' );
}
}
add_action( 'pre_get_posts', 'foo_modify_query_order' );

The 3 categories are Comedy Speakers, Sporting Speakers and Corporate Speakers.

Thank you, it would be really great if you could help us as we have done so much research but have got nowhere.
Peter

  • The forum ‘Virtue Theme’ is closed to new topics and replies.