• I got this code from https://www.atourworst.org:

    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
    rawr
    poop

    if on ask me page –
    ask me
    rawr
    poop

    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)
  • Thread Starter evenglen

    (@evenglen)

    oh yea, here is the URL to the post I found it on in case it helps:

    https://www.atourworst.org/2007/09/25/blogging-never-tasted-this-good/

    The code’s logic is backwards:

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

    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.

    Thread Starter evenglen

    (@evenglen)

    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.