posts sort alphabtically in fuctions.php
-
Hi, please I need help. There should be a code to add to the functions.php that sorts the posts alphabetically in the front-end. But I cant find it.
I found a code but it has 2 problems. It sorts only one category and it seems to have a bug, I can’t add any more code (error).
Thanks four your answers!
function modify_query_for_categories( $query ) {
if ( $query->is_category('info-a-z') ) {
$query->set( 'orderby', 'title' ); // es soll nach dem Titel sortiert werden
$query->set( 'order', 'ASC' ); // die Sortierung soll alphabetisch sein
$query->set( 'posts_per_page', '25' ); // es sollen 25 Beiträge angezeigt werden
}
}add_action( 'pre_get_posts', 'modify_query_for_categories' );
- This topic was modified 6 years, 4 months ago by .
- This topic was modified 6 years, 4 months ago by .
The page I need help with: [log in to see the link]
The topic ‘posts sort alphabtically in fuctions.php’ is closed to new replies.