• Hi – I’ve made a page template that loops all child pages with a thumbnail, title and excerpt.

    What I’d like to be able to do is to change the sort order

    Here’s the loop:

    <?php
    query_posts('&order=menu_order&post_type=page&post_parent='.$parent);
     while (have_posts()) : the_post();
    ?>
    <div <?php post_class('news-block') ?> id="post-<?php the_ID(); ?>">
    
    						<div class="thumbnail">
    							<a href="<?php the_permalink(); ?>" class="news-block-img">
    							<?php the_post_thumbnail(); ?></a>
    						</div>
    
    						<div class="news-block-text">
    							<h3><a href="<?php the_permalink() ?>" class="news-block-title" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></h3>
    							<div class="news-block-summary"><?php the_excerpt(); ?></div>
    						</div><!-- end .news-block-text /-->
    					</div><!-- end .news-block /-->
    
    <?php endwhile; ?>

    Unfortunately &order=menu_order doesn’t list the pages in the order I’ve specified (though it does list them in the correct order in the navigation)

    I’ve tried using a page order plugin as well but that doesn’t work either.

Viewing 2 replies - 1 through 2 (of 2 total)
  • https://codex.www.ads-software.com/Template_Tags/query_posts#Orderby_Parameters

    Orderby Parameters
    Sort retrieved posts by this field.

    orderby=author
    orderby=date
    orderby=title
    orderby=modified
    orderby=menu_order Note: Only works with Pages.
    orderby=parent
    orderby=ID
    orderby=rand
    orderby=meta_value Note: A meta_key=keyname must also be present in the query.
    orderby=none – no order (available with Version 2.8)
    orderby=comment_count – (available with Version 2.9)
    Order Parameters
    Designates the ascending or descending order of the ORDERBY parameter.

    order=ASC – ascending order, lowest to highest value
    order=DESC – descending order, highest to lowest value

    Thread Starter stucurry

    (@stucurry)

    Thank you very much – I see I was using order and not orderby

    Here’s my updated code which is now working in case anyone else has this issue:

    <?php
    query_posts('&order=ASC&orderby=menu_order&post_type=page&post_parent='.$parent);
     while (have_posts()) : the_post();
    ?>
    <div <?php post_class('news-block') ?> id="post-<?php the_ID(); ?>">
    
    						<div class="thumbnail">
    							<a href="<?php the_permalink(); ?>" class="news-block-img">
    							<?php the_post_thumbnail(); ?></a>
    						</div>
    
    						<div class="news-block-text">
    							<h3><a href="<?php the_permalink() ?>" class="news-block-title" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></h3>
    							<div class="news-block-summary"><?php the_excerpt(); ?></div>
    						</div><!-- end .news-block-text /-->
    					</div><!-- end .news-block /-->
    
    <?php endwhile; ?>
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Page order using the loop’ is closed to new replies.