Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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(); ?>
                            </span>
                        </div>
                        <a href="<?php the_permalink(); ?>"><?php dt_image(300, ''); ?></a>
                    <!--END .featured-image -->
                    </div>
                    <?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 -->
                    </div>

                    <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>

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

                <!--END .hentry-->  
                </div>

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

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

        <!--END #masonry -->
        </div>

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

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

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

<?php get_footer(); ?>

Edit:

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 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 at 23:56
1  
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 at 23:59

Your Answer

 
discard

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

Browse other questions tagged or ask your own question.