- This topic is empty.
-
AuthorPosts
-
June 17, 2009 at 11:16 pm #25178
hoss9009
MemberDisclaimer: 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 theTo 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:
Code:if there’s children, show here; if not, show nothing and allow the ‘recent comment’ box to move up in placeIt may be a stretch asking for that, but I thought check.
Any help would be MUCH appreciated.-Eric
June 18, 2009 at 2:30 am #59293TheDoc
MemberThe 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."
Code:post_parent)
$children = wp_list_pages(“title_li=&child_of=”.$post->post_parent.”&echo=0″);
else
$children = wp_list_pages(“title_li=&child_of=”.$post->ID.”&echo=0″);
if ($children) { ?>June 18, 2009 at 9:00 am #59191hoss9009
MemberI wasn’t planning on placing it in a widget block… am i good to go w/ this you think?
I’ll try it out today, if I have a chance.
THANK YOU!June 18, 2009 at 9:28 am #59196apostrophe
ParticipantI 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.June 22, 2009 at 3:11 pm #59538hoss9009
MemberGOT IT!!! IT WORKED!!!!
August 6, 2009 at 1:30 am #61917hoss9009
MemberOk, 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:
Code:post_parent)
$children = wp_list_pages(“title_li=&child_of=”.$post->post_parent.”&echo=0″);
else
$children = wp_list_pages(“title_li=&child_of=”.$post->ID.”&echo=0″);
if ($children) { ?>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!
August 6, 2009 at 5:30 pm #61957hoss9009
MemberOk… 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-wordpressAugust 7, 2009 at 12:28 pm #61828hoss9009
MemberOk… 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.Code:post_parent)
$children = wp_list_pages(“title_li=&child_of=”.$post->post_parent.”&echo=0″);
else
$children = wp_list_pages(“title_li=&child_of=”.$post->ID.”&echo=0″);
if ($children) { ?>post_parent) {
$parent_title = get_the_title($post->post_parent);
echo $parent_title;
?>
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?
August 7, 2009 at 1:28 pm #61833TheDoc
MemberI dig the site! Looks great.
I was just about to post some code, but then realized you already had it in there. It has to be something very simple, I feel like I’m overlooking something.
August 7, 2009 at 2:24 pm #61837hoss9009
MemberThank you…
PLEASE let me know if you come up w/ something….
Maybe a "parent_title" ?August 7, 2009 at 2:29 pm #61838hoss9009
MemberOk…. GOT IT!!!!!!!!!!!!!!!!!!
Code:post_parent);
echo $parent_title;
?>I just took out the "if" statement…
April 22, 2011 at 12:02 pm #50007jtdesign00
MemberWhat about if you wanted to make the list have a dynamic ‘current’ class?
Thanks in advanced!
August 9, 2012 at 7:18 am #107570shovan
MemberHow do you get parent page url? This is what I have
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) { ?>
August 9, 2012 at 7:19 am #107571shovan
MemberFound the solution :)
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) { ?>
Thanks
Shovan -
AuthorPosts
- The forum ‘Back End’ is closed to new topics and replies.