Skip to main content
Articles

Set ALL Posts In The Loop To Alphabetical Order

63
0

By default, WordPress will display published posts in reverse chronological order. This can be changed by adding a snippet of code to the functions.php file in the WordPress core configuration.

Useful when using the blog post roll as an index of items vs an actual blog.


function foo_modify_query_order( $query ) {
if ( $query->is_home() && $query->is_main_query() ) {
$query->set( 'orderby', 'title' );
$query->set( 'order', 'ASC' );
}
}
add_action( 'pre_get_posts', 'foo_modify_query_order' );

Corner Icon Render
Corner Icon Render
Corner Icon Render
Corner Icon Render How Can I Help You?