WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Display children of current page in summary list (5 posts)

  1. newtoncircle
    Member
    Posted 4 years ago #

    On the current website I am working on, there are a couple of main pages, with several child pages each. When the user is viewing one of the main pages, I am using the following code to list the child pages, a thumbnail for each child, and a short description.

    <?php
    $pages = get_pages('child_of='.$post->ID.'&sort_column=post_title'); $count = 0; foreach($pages as $page)	{ ?>
    
    <div class="indi">
    
    <img src="<?php $thumbpic = get_post_meta($page->ID, "Thumbnail", true);echo "".$thumbpic.""; ?>" class="thumbpic"/>
    
    <div class="story">
    
    <h4><a href="<?php echo get_page_link($page->ID) ?>"><?php echo $page->post_title ?></a></h4>
    
    <p><?php $subsum = get_post_meta($page->ID, "Summary", true);echo "".$subsum.""; ?></p>
    
    </div><div style="clear:both;" ></div></div>
    <?php } ?>

    The code works. Only one problem: the children are listed alphabetically. Can anyone tell me how to modify the above code to list the children in order of priority?

  2. Digital Raindrops
    Member
    Posted 4 years ago #

    I am new to WordPress but have looked at this and there is an $arg for sort_column=menu_order, try that and see if it is what you want.

    'post_title', 'menu_order', 'post_date', 'post_modified', 'ID', 'post_author' or 'post_name'.

    get_pages

    David

  3. newtoncircle
    Member
    Posted 4 years ago #

  4. newtoncircle
    Member
    Posted 4 years ago #

    Thanks, David. I have been coding all night and was somehow blind

  5. Digital Raindrops
    Member
    Posted 4 years ago #

    I know what you mean, I have a problem with a plugin I am working on, but it will not beat me! lol

    http://wordpress.org/support/topic/355597?replies=9

    David

Topic Closed

This topic has been closed to new replies.

About this Topic