is it possible to order posts while keeping the standard WordPress loop intact (i.e. without having to create a whole new WP_Query?
By standard loop I mean:
<?php if ( have_posts() ) : ?>
<?php /* The loop */ ?>
<?php while ( have_posts() ) : the_post(); ?>
Can I specify the order within this code?
As documented at
query_posts
function page:You can add a new action on
pre_get_posts
in your themefunctions.php
file, like:wp_reset_query() is the way to go
Example snippet
But keep in mind: query_posts() will change your main query and is not recommended. Only use if absolutely necessary (see query_posts: Caveats). Creating a new instance of WP_Query or get_posts() is preferred for secondary loops.