Support » Fixing WordPress » Show child pages in a child page?

  • I got this code from

    post->post_parent) ) { $parent = $wp_query->post->ID; } else { $parent = $wp_query->post->post_parent; } wp_list_pages(”title_li=&child_of=$parent”); ?>

    and i fixed it to be this:

    <?php if ($post->post_parent) { $parent = $wp_query->post->ID; } else { $parent = $wp_query->post->post_parent; } wp_list_pages('title_li=&child_of=$parent'); ?>

    its supposed to show the child pages on the child pages like this:

    if on about page –
    ask me

    if on ask me page –
    ask me

    iuno if i sound normal but that the best way i can explain it. can someone help me out or correct me or something? id really appreciate it. thanks.

Viewing 3 replies - 1 through 3 (of 3 total)
  • oh yea, here is the URL to the post I found it on in case it helps:

    The code’s logic is backwards:

    if ($post->post_parent) {
     $parent = $post->post_parent;
    } else {
     $parent = $post->ID;

    So when there’s a Page parent (defined in ‘post_parent’ column), $parent is assigned its ID; otherwise the current Page is (assumed to be) a parent and its ID is assigned to $parent.

    Notes: There is a change to double-quotes for the wp_list_pages() arguments — a variable inside single quotes is read by PHP literally (‘$parent’ rather than ’10’). And since we’re originally working off the $post object, there’s no reason to switch to $wp_query.

    oh thankies muchly. 🙂 i shall try it out and see how it goes.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Show child pages in a child page?’ is closed to new replies.