• Ive been trying to figure this thing out but to no avail. Here’s my situation.

    Parent Link
    Parent Link 2
    – Sub 1
    – Sub 2
    – Sub 3

    Now when I click on one of the sub pags, this is how it shows up

    – Sub 1
    – Sub 2
    – Sub 3

    What I want to do is essentially still have the first view show up regardless if I clicked on the subpages. Any help would is appreciated.

    Also heres the code I used

    <?php

    if($post->post_parent)

    $children = wp_list_pages(“depth=2&sort_column=menu_order&title_li=&child_of=”.$post->post_parent.”&echo=1″);

    else

    $children = wp_list_pages(“depth=2&sort_column=menu_order&title_li=&child_of=”.$post->ID.”&echo=1″);

    if ($children) { ?>

      <?php echo $children; ?>

    <?php } ?>`

Viewing 3 replies - 1 through 3 (of 3 total)
  • Nobody?

    I have the same problem, if anybody has a solution, please post it here!

    This is your problem i’d imagine..
    if($post->post_parent)

    That will always be true, because every post has a parent ID, just regular (non-subpages) have a parent of 0, which is the same as no parent, but doesn’t work for your IF statement above..

    List pages function isn’t reliable in some senses so i can only suggest you toy around with the code, as a starter i’d suggest changing the aforementioned line to..
    if($post->post_parent && $post->post_parent !== 0)
    or..
    if($post->post_parent !== 0)
    or..
    if($post->post_parent > 0)

    Also note the child_of parameter will still return results even where there are no pages matching the ID passed to the parameter… which i think is half the problem (and possibly a bug with that function, depending on it’s originally intended usage).

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Always show parent pages’ is closed to new replies.