Give help. Get help.
Disclaimer: I know this isn’t a WordPress site, but I’m posting this in the PHP section because my question may require a some advanced php scripting… and WordPress. :D
ok so I’m wanting to design a site that will have children to parent pages. The normal nav will be in a "index_sidebar.php".
On top of that, I will want the links of the children to appear on a "inside_sidebar.php". (inside "pages" will look different than the
To further explain my, I’ve created a framework.
Here’s a http://img200.imageshack.us/i/capturerwb.jpg/ of what I’m trying to do.
The blue is the parent nav and the red is WHERE the children nav will be (ignore the stuff that is there now).
Only 3 pages have children, so I’m wondering if there’s a cool/easy WP-php tag I could throw where the children nav would be that would ask the parent nav:
It may be a stretch asking for that, but I thought check.
Any help would be MUCH appreciated.
-Eric
The WordPress Codex is your best friend ever!
"This code will show the child pages, and only the child pages, when on a parent or on one of the children. This code will not work if placed after a widget block in the sidebar."
< ?php } ?>
I just checked an old client site and this was exactly the code I used. WordPress will even throw in the classes for you for highlighting current pages etc.
So yes, you shouldn’t have any problems.
Ok, so the code provided in this thread is AWESOME!
But….
The title of the parent page is now what I’m after..
Here’s my current code:
< ?php } ?>
My problem is <?php the_title(); ?>. I want the title of the parent to show instead of the child. This way when choosing a child, the parent title exists the same in the H3 that i have there.
I know there’s gotta be something like post_parent_title, but I’m just not sure.
Any ideas? Help!
Thanks!
Ok… I found some solutions…
This is the one I used….
http://www.tammyhartdesigns.com/tutorials/wordpress-how-to-display-the-parent-page-title-in-your-title-meta-tag/
Here’s some others…
http://wordpress.org/support/topic/270336
http://www.tammyhartdesigns.com/tutorials/wordpress-how-to-list-child-pages-in-sidebar/
http://www.fldtrace.com/wordpress/how-to-display-parent-page-title-in-wordpress
Ok… another problem.
Whem I’m on the parent, I want the parent title to show up in my nav, but it’s not.
This is the code I’m using.
< ?php } ?>
Here’s a link to the site itself… http://www.ericdmunoz.com/dhe/summer-programs/
You’ll notice that there’s a spot for an h3, but it won’t show up until you click on a child.
Any ideas how to have my cake and eat it, too?
What about if you wanted to make the list have a dynamic ‘current’ class?
Thanks in advanced!
How do you get parent page url? This is what I have
< ?php
if($post->post_parent) {
$children = wp_list_pages("title_li=&child_of=".$post->post_parent."&echo=0");
$titlenamer = get_the_title($post->post_parent);
}
else {
$children = wp_list_pages("title_li=&child_of=".$post->ID."&echo=0");
$titlenamer = get_the_title($post->ID);
}
if ($children) { ?>
- < ?php echo $titlenamer; ?>
< ?php echo $children; ?>
< ?php } ?>
Found the solution :)
< ?php
if($post->post_parent) {
$children = wp_list_pages("title_li=&child_of=".$post->post_parent."&echo=0");
$titlenamer = get_the_title($post->post_parent);
}
else {
$children = wp_list_pages("title_li=&child_of=".$post->ID."&echo=0");
$titlenamer = get_the_title($post->ID);
}
if ($children) { ?>
- post_parent) ?>">< ?php echo $titlenamer; ?>
< ?php echo $children; ?>
< ?php } ?>
Thanks
Shovan
You must be logged in to reply to this topic.