Editing a custom child page dynamic menu (1 post)

  1. iamharlan
    Posted 3 years ago #

    Hi all,

    I've got a custom "menu" of sorts that is dynamically created when the page is a child or parent. I like this versus a custom menu in this instance because my client isn't going to want to create all the separate menus. Anyway, what I've got is almost there. It's working, but has a couple of things I'd like to change.

    Here's the current code:

    <?php if($post->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) { ?>
    		  <?php echo $children; ?>
    	<?php } ?>

    With this, the child pages show up in a UL. The problem is that when a child page is selected, it still shows the child page in the ul, but the parent page is no longer linked. Is there a way to add the link to the parent page as the first link in the ul, then remove the child page that is active?

    Any help would be great. Thanks!

Topic Closed

This topic has been closed to new replies.

About this Topic