• if someone clicks on a parent page, the list of sub-pages should appear above it. i managed to do that by using the code i found here in the forums and some css.

    so this is my current code in the sidebar:

    <ul>
    <?php
    if($post->post_parent)
    $children = wp_list_pages("title_li=<h2>Sub Pages</h2>&child_of=".$post->post_parent."&echo=0"); else
    $children = wp_list_pages("title_li=<h2>Sub Pages</h2>&child_of=".$post->ID."&echo=0");
    if ($children) { ?>
    <ul>
    <?php echo $children; ?>
    </ul>
    <?php } ?>
    <?php wp_list_pages('sort_column=ID&depth=1&title_li=<h2>Pages</h2>' ); ?>
    </ul>

    example: http://ads-rantum.beachlevel.com/unser-haus/

    this shows the sub-pages (called ”extra seiten“ in the example) above the list of the parent pages (called ”seiten“ in the example). but when i click on a sub-sub-page now, the first sub-page disappears from the list. same with clicking on a sub-sub-sub-page, now the sub-sub-page disappears as well.

    now i need something, so the parent of a sub will be listed, even if that parent is a sub itself (i call it a faked parent for now).

    anyone with an idea, my fellow wp users? 😉

Viewing 4 replies - 1 through 4 (of 4 total)
  • Thread Starter martensen

    (@martensen)

    Well, i saw that there are some solutions already whipped up by Code Overlord Kafkaesqui, but since i don’t speak fluent php, i kinda need my own code modified and ready to be pasted, since i have no clue where to start and end my copy/paste process.

    So a big SORRY for that in advance.

    Here is my complete left sidebar code:

    <div id="sidebar_left">
    		<ul>
    			<?php
    			if($post->post_parent)
    			$children = wp_list_pages("title_li=<h2>Extra Seiten</h2>&child_of=".$post->post_parent."&echo=0"); else
    			$children = wp_list_pages("title_li=<h2>Extra Seiten</h2>&child_of=".$post->ID."&echo=0");
    			if ($children) { ?>
    			<ul>
    			<?php echo $children; ?>
    			</ul>
    			<?php } ?>
    			<?php wp_list_pages('exclude=51,64,67&sort_column=ID&depth=1&title_li=<h2>Seiten</h2>' ); ?>
    		</ul>
    </div>

    Site url again: http://ads-rantum.beachlevel.com/unser-haus/

    Thread Starter martensen

    (@martensen)

    I had another idea.

    Instead of using the fixed title_li=<h2>Fixed title</h2>
    i use as headline for the subpage list, i could use something
    dynamic that displays the parents title.

    I mean like this:

    wp_list_pages("title_li=__TITLE_OF_PARENT_PAGE__&child_of=".$post->post_parent."&echo=0")

    Is that possible somehow?

    please let it be possible!! im looking for this too

    Thread Starter martensen

    (@martensen)

    Well, the closest i found was the breadcrumb plugin.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘display sub-page, even if on a sub-sub-page’ is closed to new replies.