WordPress.org

Forums

Changing my loop order to descending - new to old (2 posts)

  1. onestrangecat
    Member
    Posted 1 year ago #

    I'm having a struggle getting my posts to display in descending order. I've tried several things to no avail. Any help in troubleshooting this would be incredibly helpful. This is the code that exists within my loop-index.php page. The site in question is http://onestrangecat.com

    <?php
    /**
     * Loop for home page.
     *
     * @package WordPress
     * @subpackage themeName
     * @since themeName 1.0
     */
    ?>
    <?php if (have_posts()) : ?>
    		<?php query_posts($query_string . '&orderby=date&order=DESC'); ?>
            <?php while (have_posts()) : the_post(); ?>
                    <div class="post">
                            <h2 class="post-title"><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2>
                            <?php if(is_single()) : ?>
                                    <?php the_content(); ?>
                            <?php else : ?>
                                    <?php the_excerpt(); ?>
                            <?php endif; ?>
                    </div>
            <?php endwhile; ?>
    <?php endif; ?>
    
    <?php /* Display navigation to next/previous pages when applicable */ ?>
    <?php if ($wp_query->max_num_pages > 1) : ?>
            <div id="nav-below" class="navigation">
                    <div class="nav-previous"><?php next_posts_link(__('<span class="meta-nav">&larr;</span> Older posts', 'themeName')); ?></div>
                    <div class="nav-next"><?php previous_posts_link(__('Newer posts <span class="meta-nav">&rarr;</span>', 'themeName')); ?></div>
            </div><!-- #nav-below -->
    <?php endif; ?>

    Cheers,
    Josh

  2. Pioneer Valley Web Design
    Member
    Posted 1 year ago #

    <?php query_posts($query_string . '&orderby=date&order=DESC'); ?>

    Sorts the posts by date in descending order,

    So...this must not be the template used. It also may not be necessary as the default sort order for posts is by date, descending.

    What happens if you switch to default theme?

Topic Closed

This topic has been closed to new replies.

About this Topic