• Resolved dwzemens

    (@dwzemens)


    I have some custom PHP written to show, in a sidebar, the navigation for the site.

    <?php if(is_404() or is_search()) : ?>
    	<!--put here what you want to show on your 404 and searchresults pages instead of the childpages-->
    	<?php else : ?>
    	<?php
    		if($post->post_parent)  // If this is a Child page
    		$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");  // This is a Parent page
    		if ($children) { ?>
    		<ul class="subnav">
    			<li><h2 class="menu-image"><small><em>more choices</em></small><br /><?php echo($parent_title = get_the_title($post->post_parent)); ?></h2></li>
    		<?php include("recent-news-edu.php"); ?>
    		<?php echo $children; ?>
    		</ul>
    	<?php } ?>
    
    <?php endif; ?>

    The test site is located at:
    https://gator956.hostgator.com/~dwzemens/worship/mass-times/

    Here’s the client’s question that I cannot solve:
    Is it possible to reconfigure the way the sidebar menus show up, so that the entire section appears (like the entire WORSHIP section) whenever a visitor is in ANY part of the worship pages? For example, if I go to WORSHIP I see a full index of WORSHIP, then I click on SACRAMENTS and see a full index of WORSHIP, then I click on BAPTISM, and I’d like to still see that full index, but I only get the SACRAMENT index.

    Can anyone offer any help for me by a modification to this code or by suggesting some other method?

    Thanks so very much for the help.

Viewing 1 replies (of 1 total)
  • Thread Starter dwzemens

    (@dwzemens)

    For those interested here is how I solved the problem:

    <!--
    https://diggingintowordpress.com/2009/07/delicious-recipes-wordpress-page-menus/
    -->
    <?php if(is_404() or is_search()) : ?>
    	<!--put here what you want to show on your 404 and searchresults pages instead of the childpages-->
    	<?php else : ?>
    	<?php
    		if($post->post_parent)  // If this is a Child page
    			{
    				$children = wp_list_pages("title_li=&child_of=".$post->post_parent."&echo=0");
    				//echo("Sub Level Menu");
    				$this_post = $post->post_parent;
    				//echo("X--.$this_post.--X");
    
    				//  https://www.ads-software.com/support/topic/252513?replies=5
    				$ancestors = get_post_ancestors($post);
    				$root=count($ancestors)-1;
    				//echo "root page id  is >> " . $ancestors[$root];
    				$da_child = $ancestors[$root];
    
    				// https://www.ads-software.com/support/topic/227954?replies=6
    				//if (in_array(854,$ancestors)) echo "--854 is an ancestor of the post";
    				// Get the entire page list from the topmost ancestore down using $da_child variable below
    				$children = wp_list_pages("title_li=&child_of=$da_child&echo=0"); // Baptism sub page
    			}
    			else
    			{
    				$children = wp_list_pages("title_li=&child_of=".$post->ID."&echo=0");  // This is a Parent page
    				//echo("Top Level Menu");
    			}
    		if ($children)
    			{ ?>
    				<ul class="subnav">
    				<!-- only display title for top level ancestor page -->
    				<li><h2 class="menu-image"><small><em>more choices</em></small><br /><?php echo($parent_title = get_the_title($da_child)); ?></h2></li>
    				<!--<li><h2 class="menu-image"><small><em>more choices</em></small><br />< ?php echo($parent_title = get_the_title($post->post_parent)); ?></h2></li>-->
    				<?php include("recent-news-edu.php"); ?>
    				<?php echo $children; ?>
    				<?php //echo $ancestors; ?>
    			</ul>
    	<?php } ?>
    <?php endif; ?>

Viewing 1 replies (of 1 total)
  • The topic ‘‘folding’ navigation list problem – custom code’ is closed to new replies.