• Is it possible to get all the sub pages displayed in the parent page? so when you add a sub page it will automatically appear in the parent page??

    Any help would be great.

Viewing 2 replies - 1 through 2 (of 2 total)
  • rocksoup

    (@rocksoup)

    Ah, me too. I am having this problem. I have a site where the page “About” has 5 sub-pages, each with a page order assigned. I am using this code to display the sub-pages in the about page:

    <?php $defaults = array(
    'depth' => 0, 'show_date' => '',
    'date_format' => get_option('date_format'),
    'child_of' => 2, 'exclude' => '',
    'title_li' => __('Pages'), 'echo' => 1, 'authors' => '', 'sort_column' => 'page_order') ;
    
    $r = wp_parse_args( $args, $defaults );
    
    $all_pages = get_pages($args);
    
    foreach($all_pages as $page) :
    
    if ($page->post_parent == $post->ID){ ?>
    <div class="section">
    
    <? $get_thumbnail = get_post_meta($page->ID, 'section-thumbnail', true);
    if ($get_thumbnail != ''){
    
    ?>
    
    <img src="https://localhost/****/img/<?=$get_thumbnail ?>"/>
    <? } ?>
    <a class="move" href="#"><h1> <?=$page->post_title ?> </h1> </a>
    <div class="sub_section" >
    
         <?=$page->post_content ?>
            <p class="clear"></p>
         </div>
    </div>
    <?
    }
    endforeach;
    ?>

    This is excellent at pulling the sub-pages into the parent, but I can not figure out how to sort them. The sort_column is not showing me the desired effect, which is to sort by page order. The sub-pages are sorting alphabetically. Any help is greatly appreciated.

    btw- first post – first WP site

    rocksoup

    (@rocksoup)

    to answer my own request.

    a kind soul told me to do this to fix it-

    remove from above:

    $defaults = array(
    'depth' => 0, 'show_date' => '',
    'date_format' => get_option('date_format'),
    'child_of' => 2, 'exclude' => '',
    'title_li' => __('Pages'), 'echo' => 1, 'authors' => '', 'sort_column' => 'page_order') ;

    $r = wp_parse_args( $args, $defaults );

    and replace the :

    $all_pages = get_pages($args);

    with:

    $all_pages = get_pages( 'hierarchical=0&sort_column=menu_order' );

    works great now

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Sub Pages?’ is closed to new replies.