WordPress.org

Ready to get started?Download WordPress

Forums

Sort by post stamp date in paginated category is not working (2 posts)

  1. marc0047
    Member
    Posted 7 years ago #

    I'm having a difficult time getting a category listing to show posts by time stamp. Right now it's displaying posts in order of ID number.

    Have I setup the following code correctly?

    <?php $page = (get_query_var('paged')) ? get_query_var('paged') : 1; ?>
    <?php if ( is_category('4') ) { query_posts("cat=4&showposts=20&paged=$page&orderby=date&order=DESC"); } ?>
    <?php if ( is_category('6') ) { query_posts("cat=6&showposts=20&paged=$page&orderby=date&order=DESC"); } ?>
    <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
    <a href="<?php the_permalink(); ?>" id="item-<?php the_ID(); ?>">
    <span class="product-title"><?php the_title(); ?></span>
    </a>
    <?php endwhile; else: ?>
    <p><?php _e('Sorry, no posts matched your criteria.'); ?></p>
    <?php endif; ?>

  2. MichaelH
    Member
    Posted 7 years ago #

    I haven't tested this but have your tried orderby=post_date?

Topic Closed

This topic has been closed to new replies.

About this Topic