Order by asc post in category page with functions.php
-
Hi,
I would order by asc posts in category page with functions.php in child theme.
I’ve tried to use this code (found here):// Runs before the posts are fetched
add_filter( ‘pre_get_posts’ , ‘my_change_order’ );
// Function accepting current query
function my_change_order( $query ) {
// Check if the query is for an archive
if($query->is_archive)
// Query was for archive, then set order
$query->set( ‘order’ , ‘asc’ );
// Return the query (else there’s no more query, oops!)
return $query;
}but it doesn’t work.
I’ve the last version of WP, should I change perhaps pre_get_posts ?!Thanks.
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘Order by asc post in category page with functions.php’ is closed to new replies.