Here’s an example which assumes you have 2 custom post types created , one name portfolio and the other community.
The code simply displays all single pages you publish as custom post types in Alphabetical order in each CPT archive.
Original Genesis & WooCommerce Tutorials & 6000+ Guaranteed Code
Snippets
I’m trying to make some categories to be sorted alfabethical and the rest by date as is normal. I tried adding this code to the functions.php
/** Order Posts A-Z on Category Pages **/
function be_category_query( $query ) {
if( $query->is_main_query() && $query->is_category(560) && !is_admin() ) {
$query->set( ‘orderby’, ‘title’ );
$query->set( ‘order’, ‘ASC’ );
}
}
add_action( ‘pre_get_posts’, ‘be_category_query’ );
/** end of a-z **/
It works fine as long as I have only one category -ID but if I have two or more ,
is_category(560,561,562)
it still just works for the first category.
I am using the theme Pretty Creative.
Sorry- you can skip my comment, right after I posted I found the error. No array
I assume you need this
Yepp,exactly