WordPress.org

Forums

[resolved] Could use a quick genius for a second. MichaelH? (3 posts)

  1. xroox
    Member
    Posted 3 years ago #

    Hi there,

    MichaelH the volunteer wrote this nifty code to show pages in a widget space using the 'PHP Code Widget':

    <?php
    global $post;
    $output = wp_list_pages('echo=0&depth=1&title_li=<h2>Top Level Pages </h2>' );
    if (is_page( )) {
      $page = $post->ID;
      if ($post->post_parent) {
        $page = $post->post_parent;
      }
      $children=wp_list_pages( 'echo=0&child_of=' . $page . '&title_li=' );
      if ($children) {
        $output = wp_list_pages ('echo=0&child_of=' . $page . '&title_li=<h2>Child Pages</h2>');
      }
    }
    echo $output;
    ?>

    This is so close to what I am after!

    What I'm trying to do is show only the sub-pages of one particular parent page, and not all parent pages by default. So the top level would be a particular parent, and then it's sub pages.

    Would anyone be able to tweak this code to achieve this? I would be most, most appreciative.

    The original thread is here. http://wordpress.org/support/topic/different-menus-on-different-pages?replies=8

    MichaelH if you're still around I would super-appreciate a leg-up. Thanks so much.

  2. xroox
    Member
    Posted 3 years ago #

    To put this in context, I would like to have the sub pages of the "services" page show up on the home page, and any other page with no parents.

    For child pages of "services," I would like to show their contemporaries.

    Hope this makes sense!

  3. xroox
    Member
    Posted 3 years ago #

    I have found a solution using Woothemes.

Topic Closed

This topic has been closed to new replies.

About this Topic