WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I developed a site for a client using a premade theme called "Adapt". When I was developing on my own server, the blog posts were posting as they should in descending order (i.e. new to old with new being on top). However, when I moved the completed work to my client's server and imported his blog posts from his old site, the posts started displaying in ascending order (i.e. old to new with old being on top).

I've tried deactivating all plugins but the problem remains. I've also tried adding <?php query_posts($query_string . '&orderby=date&order=DESC'); ?> right before <?php if (have_posts()) : ?>, but nothing changed.

The funny thing is that the blogs on the archive pages are behaving as they should. The posts are shown from new to old, with new being on top.

Below is the code for the index page where the blogs are behaving this way. Any help in getting this sorted out would be appreciated. Thank you.

<?php get_header(); ?>

    <?php if (dt_is_sidebar_active('homepage_ad')) : ?>
        <div id="homepage-ad" class="widget-area">
                <?php dynamic_sidebar('homepage_ad'); ?>
        </div><!-- #homepage-ad .widget-area -->
    <?php endif; ?>

    <!--BEGIN #content -->
    <div id="content">

        <div id="sidebar">
            <div id="home-sidebar" class="widget-area">
                    <?php get_sidebar(); ?>
            </div><!-- #home-sidebar .widget-area -->
        </div><!-- #sidebar -->

        <!--BEGIN #masonry -->  
        <div id="masonry">

            <?php if (have_posts()) : while (have_posts()) : the_post(); ?>

            <!--BEGIN .item --> 
            <div class="item normal" data-order='1'>

                <!--BEGIN .hentry -->
                <div <?php post_class(); ?> id="post-<?php the_ID(); ?>">

                    <?php if ( has_post_thumbnail() ) : ?>
                    <!--BEGIN .featured-image -->
                    <div class="featured-image">
                        <div class="da-hover">
                            <span class="da-wrap">
                                <span class="title"><?php the_title(); ?></span>
                                <?php dt_overlay_icon(); ?>
                        <a href="<?php the_permalink(); ?>"><?php dt_image(300, ''); ?></a>
                    <!--END .featured-image -->
                    <?php endif; ?>

                    <span class="meta-category"><?php the_category(', '); ?></span>

                    <h2 class="post-title"><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2>

                    <!--BEGIN .post-content -->
                    <div class="post-content">

                        <?php $format = get_post_format(); ?>
                        <?php if ($format == "image" || $format == "gallery" || $format == "video") : ?>
                        <span class="icon"><img src="<?php echo get_template_directory_uri(); ?>/images/icon-<?php echo $format; ?>.png" alt="<?php echo $format; ?>" /></span>
                        <?php endif; ?>

                        <?php dt_excerpt(20); ?>

                    <!--END .post-content -->

                    <a class="read-more" href="<?php the_permalink(); ?>"><?php _e('Read More', 'engine'); ?></a>

                    <!--BEGIN .post-footer -->
                    <div class="post-footer">

                        <span class="meta-published"><?php echo human_time_diff( get_the_time('U'), current_time('timestamp') ) . ' '.  __('ago', 'engine'); ?></span>

                        <span class="meta-comments"><?php comments_number(__('No Comments', 'engine'), __('1 Comment', 'engine'), __('% Comments', 'engine')); ?></span>

                    <!--END .post-footer -->

                <!--END .hentry-->  

            <!--END .item -->   
            <?php endwhile; endif; ?>

            <?php get_template_part('includes/index-loadmore'); ?>

        <!--END #masonry -->

        <div id="masonry-new"></div>

        <!--BEGIN .post-navigation -->
        <div class="post-navigation clearfix">
            <?php dt_pagination(); ?>
        <!--END .post-navigation -->

    </div><!-- #content -->

<?php get_footer(); ?>


This (in functions.php) was the culprit:

function excludeCat($query) {
    if ( $query->is_home ) {
        $query->set('cat', '-5377');
    return $query;
add_filter('pre_get_posts', 'excludeCat');
share|improve this question
You've deactivated all plugins; have you tried switching to a default theme (like Twenty Fourteen) to see if it's something in the theme you're using? – Pat J Jun 27 '14 at 23:45
@PatJ Yes, I did just now (with all plugins activated) and the blogs were posted in the correct descending order. So I guess it has something to do with the theme. I'm having a tough time figuring out what could be wrong. – Desi Jun 27 '14 at 23:56
Check in the theme's functions.php and other files for anything using query_posts() (which shouldn't be used -- see the discussion here) or pre_get_posts or WP_Query. You're looking for anything that sets the order parameter. That's where I'd start. – Pat J Jun 27 '14 at 23:59

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.