How to combine strings in code
-
Hi
I am using this code to reverse sort order for certain categories. I have 66 categories to list. Is there some way of combining the query and adding the 66 ids into one line please?
/* Reverse default date descending order for specific categories */ function change_category_order( $query ) { //Sort all posts from category with id=19 (interviews) by date asc order if($query->is_category('413') && $query->is_main_query()){ $query->set( 'order', 'ASC' ); } if($query->is_category('447') && $query->is_main_query()){ $query->set( 'order', 'ASC' ); } if($query->is_category('448') && $query->is_main_query()){ $query->set( 'order', 'ASC' ); } if($query->is_category('449') && $query->is_main_query()){ $query->set( 'order', 'ASC' ); } if($query->is_category('450') && $query->is_main_query()){ $query->set( 'order', 'ASC' ); } } add_action( 'pre_get_posts', 'change_category_order' );
Thanks
Rich
The page I need help with: [log in to see the link]
Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
- The topic ‘How to combine strings in code’ is closed to new replies.