• I would like to list the sub pages inside a page. I am using runPHP to run php inside my page… For some reason this piece of script returns “4” ?!?!

    <?php
    $current_page_id = the_ID();
    wp_list_pages("child_of=$current_page_id");
    ?>

Viewing 3 replies - 1 through 3 (of 3 total)
  • the_ID() doesn’t return the ID for use in PHP, it inserts it into the page, which is why it’s showing up.

    Try this:

    wp_list_pages("child_of=$id");

    and if that doesn’t work and the following just before it:

    global $id;

    where do u put this code?? has it worked yet??

    i too want to show my sub pages in my parent page..

    this code works perfectly, and unlike a lot of code floating around the support forums, it also displays the submenu when you’re on child page:

    <ul>
    <?php if(get_the_title($post->post_parent) != the_title(' ' , ' ',false)) {
    	wp_list_pages("child_of=".$post->post_parent."&sort_column=menu_order&title_li=");
    
    } else {
    
    	wp_list_pages("child_of=".$post->ID."&sort_column=menu_order&title_li=");
    }
    
    ?>
    </ul>
Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘List sub pages inside a page… hmmm :)’ is closed to new replies.