Hello GP Friends,
I would like site visitors to have the ability to browse the individual posts by category, sorted by post title.
Objectives:
— All queries in the site are sorted by Post Title, ascending (and never by date)
— All posts have just one category
— When the user goes to a single post page, the navigation for previous/next posts stays within the category for that post. The previous/next will be sorted by Title
QUESTION:
How can I change the single post navigation to follow the post’s category loop, sorted by Title?
I am currently using two code snippets.
The first is to stay within the category.
The second is to order queries by title.
add_action( ‘after_setup_theme’, ‘mdp_category_specific_post_navigation’ );
function mdp_category_specific_post_navigation() {
add_filter( ‘generate_category_post_navigation’, ‘__return_true’ );
}
add_action( ‘pre_get_posts’, ‘mdp_modify_query_order’ );
function mdp_modify_query_order( $query ) {
$query->set( ‘orderby’, ‘title’ );
$query->set( ‘order’, ‘ASC’ );
}
Many thanks,
Denise
(question updated and clarified on 2/22/2018 at 4:35 CST)