I just purchased a WordPress theme. I’m trying to sort post on one category into an alphabetical listing (glossary type of listing).
Example : /
There are using a WordPress theme, I just don’t know how to create that.
I have tried several plugins (like A-Z Listing and others) but it doesn't look good at all.
Could you please help me please ? Do you know a plugin or a way to create this please ?
thank you
I just purchased a WordPress theme. I’m trying to sort post on one category into an alphabetical listing (glossary type of listing).
Example : https://www.udiscovermusic.com/browse-artists/
There are using a WordPress theme, I just don’t know how to create that.
I have tried several plugins (like A-Z Listing and others) but it doesn't look good at all.
Could you please help me please ? Do you know a plugin or a way to create this please ?
thank you
You can change the sort order on a category archive page to show posts by title (A-Z) by adding this code to your child theme's functions.php:
/* Sort posts by title for a specific category */
function change_category_order( $query ) {
//Sort all posts from category with id=3 by title
if($query->is_category('3') && $query->is_main_query()){
$query->query_vars['orderby'] = 'name';
$query->query_vars['order'] = 'DESC';
}
}
add_action( 'pre_get_posts', 'change_category_order' );
You need to replace "3" with the correct category id. You can find out the category id by heading to dashboard => post => categories and hover over the category you want to adjust the sort order.