Support » Fixing WordPress » query child pages and orderby date and pagination

  • Hi, i have 20 subpages in parent page and tried to list child pages by 10 pages, add next and prev link, AND sort by post date.
    There is no problem to query child pages and display list by 10 pages per page. But if adding orderby and order parameter, list is sorted propably in order creation date. So if i change date of older page in admin to newest, is displayed still in midle of list, where was before. No change. How can i sort this ‘page loop’ by date?

    I used following code:

    <?php /* THE NEW LOOP */
    query_posts(array('post_parent' => $this_page_id, 'paged' => $paged, 'post_type' => 'page', 'posts_per_page' => 10, 'orderby' => 'date', 'order' => 'ASC'));
    global $more; $more = 0;
    while (have_posts()) : the_post(); ?>
    <div class="post single">
    <a href="<?php echo get_permalink(); ?>"><h2 class="job_title"><?php the_title(); ?></h2></a>
    <?php $m_link = get_permalink().'#more-'.$post->ID; ?>
    <a href="<?php echo $m_link; ?>" class="job_more">Display detail</a>
    <div class="cleardiv"></div>
    <?php endwhile; ?>
    <br /><br />
    <div class="float-left"><?php next_posts_link('« Previous page inzeráty') ?></div>
    <div class="float-right"><?php previous_posts_link('Next page »') ?></div>
    <?php wp_reset_query(); ?>

    seems to there is a bug?

    Thanks, for tips!

  • The topic ‘query child pages and orderby date and pagination’ is closed to new replies.