Post order by title, except category # and #
-
Using code below to display posts in alphabetical order, but I want to exclude categories 7 & 9. How would I do this?
function custom_order_category( $query ) { // exit out if it's the admin or it isn't the main query if ( is_admin() || ! $query->is_main_query() ) { return; } // order category archives by title in ascending order if ( is_category() ) { $query->set( 'order' , 'asc' ); $query->set( 'orderby', 'title'); return; } } add_action( 'pre_get_posts', 'custom_order_category', 1 );
Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
- The topic ‘Post order by title, except category # and #’ is closed to new replies.