Support » Fixing WordPress » Archive oldest to newest post

  • I am looking for a way to change the order of our Monthly Archives from the oldest post first to the newest.

    The url that shows the monthly Archive is http://wordpress-site.com/2012/06.

    I have looked at archive.php, but there is no wp query to modify.

    Sorry if this is a dumb question, but where can I specify the order of the posts?

    tx

    Wil

Viewing 3 replies - 1 through 3 (of 3 total)
  • Hi,

    I would do it by creating a custom query.

    On your archive.php page, replace this:

    <?php
    	/* Since we called the_post() above, we need to
    	 * rewind the loop back to the beginning that way
    	 * we can run the loop properly, in full.
    	 */
    	rewind_posts();
    
    	/* Run the loop for the archives page to output the posts.
    	 * If you want to overload this in a child theme then include a file
    	 * called loop-archive.php and that will be used instead.
    	 */
    	 get_template_part( 'loop', 'archive' );
    ?>
    

    With this:

    <?php
    $paged = get_query_var('paged') ? get_query_var('paged') : 1;
    $args = array( 'paged' => $paged, 'posts_per_page' => 10, 'orderby' => ASC );
    // The Query
    query_posts( $args );
    // The Loop
    while ( have_posts() ) : the_post(); ?>
    

    Hey thanks for the response – The only thing I see on the Archive.php is this…

    <?php $i = 1; ?>
    <?php if (have_posts()) : ?>

    and

    <?php $post = $posts[0]; /* Hack. Set $post so that the_date() works. */ ?>
    <?php while (have_posts()) : the_post(); ?>
    <?php if ($i == 1) : ?>

    I tried your query, but it didn’t work.

    tx

    Wil

    If you are using a premium template, you should contact the developer.

    The code you have above isn’t the standard loop query for the archive.php page.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Archive oldest to newest post’ is closed to new replies.