I have a page that is using a Custom Post Type called ‘Articles’.
I’m wondering how to query the content to order the ‘Articles’ on the frontend by Title in ASC, but the posting of ‘Articles’ on the frontend needs to be by a specific category and not modify any other post listings.
I tried developing this within the ‘functions.php’:
function alpha_order_classes( $query ) {
if ( $query->is_post_type_archive('Articles') && $query->is_main_query() ) {
$query->set( 'orderby', 'title' );
$query->set( 'order', 'ASC' );
}
}
But I’m not seeing any results or any errors on the frontend. I would prefer to use a function within the functions.php file rather than manipulating the template file, if at all possible.
The template that needs to be modified is NOT the category.php template. Instead it uses the page-template.php and references the loop.php file.
Thank you.