Children, Parents, Custom Menu
-
I’m using the following code. To display parents of children. I looked on the wordpress codex, but I’m not really that great with PHP and could use some help. Originally I wanted to display the PARENT and it’s children no matter what child you’re on. However, I made some site changes and now want to display PARENT no matter which child you’re on UNLESS you’re on a child that has children of its own.
using this code:
<?php global $post; 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 } ?> <h3 class="Header"><?php echo $titlenamer; ?></a></h3> <ul class="Menu"><?php echo $children; ?></ul> </div>
The header is where I need the Title of the PARENT or Child (only if it has children)
and the menu is where i need the children of the part or the child.Got this help on another forum, but got completely lost?
The way to handle this would be to identify if the page had children first, then use the post id as teh “parent” in the list or find the parent if available and use that or just list all failing either.
- The topic ‘Children, Parents, Custom Menu’ is closed to new replies.