http://wordpress.org/support/topic/38298
Take a look at this thread, and see if it is close to what you want to do. If not, let us know.
Thread Starter
nobody
(@paitrakt)
I think what I want to do is quite the same as in the thread you linked to, but I need a 100% dynamical solution. My dad can’t edit templates and put in extra PHP-code every time he creates a new subpage.
I tried to edit the _page_level_out-function in WP, but it didn’t work perfectly. Subpages are now displayed if the parent is viewed, but not if one of the subpages is viewed. I replaced line 398 (i think) in template-functions-post.php with this:
if(isset($cur_page[‘children’]) && $_GET[‘pagename’] == $cur_page[‘name’]) {
Hey,
Just a thought, have you tried creating your own functions with relevant queries to find out subpages?? I’m not sure exactly on the queries but sometimes you have to think out of the constraints of WP to take your site the extra mile. Have a look at the WP tables see if there are any queries you can make to create a getChildPages() function and use this within page.php (the Page template) to check for child pages for the given page
Something like:
if(getChildPages() > 0)
//print the child pages
And of course, since we all like to keep code as reusable as possible, I would stick this in a <theme_functions>.php file. Then all we need to do is include (require_once would be better) this in the top of the header.php file.
If your still unsure of what I’m talking about, checkout the BX_functions.php in the Blix theme. See how he’s created some custom functions? Neat eh?
I was struggling with this same issue, but it occurred to me that you could do it with these CSS rules:
.page_item ul li {
display: none;
}
.current_page_item ul li, .page_item .current_page_item {
display: block;
}
Hope that helps.
It might work for you – but being a general rule, it will prevent displaying those list items even where you want to show them.
or you could try the awesome ‘Fold Page List’ plugin 🙂
http://www.webspaceworks.com/resources/wordpress/30/
I think this plug-in will do what you need:
http://www.mealldubh.org/index.php/software/fold_page_menus/
I use it on my site. It’s been working well.
The fold plug-in is good but if you want to only show the subpages when you are in the parent how do you do that?
let’s say you’re in http://www.blog.com/
you will see:
page 1
page 2
but if you are in http://www.blog.com/page 1
you will only see:
page 1a
page 1b
You will not see page 2.
Can this be done? Is there an easy solution?
SB
(@sambritt)
I am also trying to figure out to only show the subpages when you are in the parent page.
If I knew how to create plug-ins for this subject matter, I would create one now…