• I am trying to list one specific parent page and all the children under it. The output is simply the permalink and the custom field.

    I have got all the children of the parent, but I don’t know how to have that parent also output.

    Your help would be greatly appreciated.

    This is what I have so far:

    <?php
    $pageChildren = get_pages('child_of=1844');
    if ( $pageChildren ) {
      foreach ( $pageChildren as $pageChild ) {
        $meta = get_post_meta($pageChild->ID, 'submenu-extratext', true);
        echo '<li><a href="' . get_permalink($pageChild->ID) . '">'. $meta .'</a></li>
    ';
        }
      }
    ?>
Viewing 3 replies - 1 through 3 (of 3 total)
  • Moderator bcworkz

    (@bcworkz)

    <?php
    $id = 1844;
    $parent = get_page( $id );
    echo '<li><a href="' . get_permalink($parent->ID) . '">'. $parent->post_title .'</a></li>;
    $pageChildren = get_pages("child_of=$id");
    //etc....

    I labeled the parent link with it’s title, you can change it to something else of course. If that something else is not reliant on the parent page data, you do not need get_page(), since you already have the ID without it.

    You would think this could be done as part of the call to get_pages(). You might be able to, but it’s complicated. Just do it separately.

    Thread Starter Bill Weye

    (@billhector)

    This is too crazy. I need to get a custom field value, which is working fine in get_pages, but it’s not possible to get meta values in get_page.

    Strange.

    Does anyone have any ideas?

    Thanks

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘list parent & children with custom field data too’ is closed to new replies.