treehouse : what would you like to learn today?
Web Design Web Development iOS Development

[Solved] Wordpress: New pages won't go in query order?

  • Hi there,

    I have a query, like so:

    
    <?php query_posts('post_type=page&order=ASC&post_parent=20&posts_per_page=-1'); while (have_posts()) : the_post (); ?>
    

    Which has worked fine, until I started adding new pages. Those new pages I added won't go in order. They seem to be bunched up together.

    The new posts I created are not sticky posts (although I don't think pages can be). I noticed the older pages, that are arranged, were added on a specific date. Thinking that might solve it, I adjusted the date, but that didn't work.

    I also tried wp_reset_query, but that didn't work either. Weird. Thoughts?

  • Try adding orderby=date to the query string

  • Oh yeah, there is an "orderby". This worked!

    <?php wp_reset_query(); query_posts('post_type=page&post_parent=20&posts_per_page=-1&orderby=title&order=asc'); while (have_posts()) : the_post (); ?>

    Thank you!