How can I leave the blog post in the ASC order only in a category?
I found this code::
add_filter('avia_blog_post_query', 'avia_modify_post_grid_query_asc');
function avia_modify_post_grid_query_desc( $query ) {
$query['orderby'] = 'date';
$query['order'] = 'ASC';
return $query;
}
But I think this will change the order of the entire site and not just one category.
Hey elitontorri,
Thank you for using Enfold.
Use the is_page function to specify the page where you want the filter to be applied.
// https://developer.wordpress.org/reference/functions/is_page/
add_filter('avia_blog_post_query', 'avia_modify_post_grid_query_asc');
function avia_modify_post_grid_query_desc( $query ) {
if(is_page(PAGE ID HERE)) {
$query['orderby'] = 'date';
$query['order'] = 'ASC';
}
return $query;
}
Change the “PAGE ID HERE” text to the actual ID of the page.
Best regards,
Ismael