WordPress.org

Ready to get started?Download WordPress

Forums

Using parent slug variable to display proper submenu not working properly (1 post)

  1. edgarfigaro
    Member
    Posted 10 months ago #

    There are three submenus I have which display based on where you are in the site using the "the_parent_slug()" function. (personal-liability, life-and-health, and business) So when I use the search box at the top of the page and search for the following terms, the submenu shows up. It seems if those words are in the URL at all, it triggers the submenu to load. They are "Personal Liability" and "Life". Can anyone provide assistance in this matter.

    Code and link to follow:

    http://s168249.gridserver.com/

    <?php $parent_slug = the_parent_slug(); ?>
    
    	<?php if(is_page('personal-liability') || $parent_slug == 'personal-liability') { ?>
    		<div id="secondary_menu" class="personal-menu">
    			<div id="secondary_menu_inside">
    				<?php wp_nav_menu( array( 'container_class' => 'menu-header3', 'theme_location' => 'personal' ) ); ?>
    			</div>
    		</div>
    	<?php } else if(is_page('life-and-health') || $parent_slug == 'life-and-health') { ?>
    		<div id="secondary_menu" class="life-and-health-menu">
    			<div id="secondary_menu_inside">
    				<?php wp_nav_menu( array( 'container_class' => 'menu-header3', 'theme_location' => 'life-and-health' ) ); ?>
    			</div>
    		</div>
    	<?php } else if(is_page('business') || $parent_slug == 'business') { ?>
    		<div id="secondary_menu" class="commercial-menu">
    			<div id="secondary_menu_inside">
    				<h3 class="business_menu_header1">Areas of Expertise</h3><h3 class="business_menu_header2">Policy Types</h3>
    				<?php wp_nav_menu( array( 'container_class' => 'menu-header3 business', 'theme_location' => 'business' ) ); ?>
    				<?php wp_nav_menu( array( 'container_class' => 'menu-header3 business2', 'theme_location' => 'business2' ) ); ?>
    			</div>
    		</div>
    	<?php } else if(is_page('claims')) { ?>
    		<div id="secondary_menu" class="claims-menu">
    		</div>
    	<?php } ?>

Reply

You must log in to post.

About this Topic