Force secondary Nav to display on certain pages

Greetings,

I’m having an issue with a secondary navigation that doesn’t appear on certain page views of a calendar plugin that I’m using called The Events Calendar Pro. It doesn’t appear on pages other than those I have in the sub menu (Main page & Events Calendar page). I’ve discovered that this is not an issue with the Events Calendar plugin, or the theme I'm using. I’ve posted on each of their forums and support sections. It’s actually an issue with a feature that I’m using to display submenu items as a secondary navigation. I found the code for this plugin here:
http://christianvarga.com/how-to-get-submenu-items-from-a-wordpress-menu-based-on-parent-or-sibling/

It allows you to display a secondary navigation based on the menu you create in the ‘Appearance > Menus’ section of the WP backend. However, because I have not added every event view to the Events section of my menu the secondary nav bar doesn’t show up on the other view or on individual event pages. Adding all the event views and event pages would be tedious and would look really cluttered.

So now here is my question: How can I have the secondary menu that appears on the main Events page appear on all pages that are created by The Events Calendar plugin? Is there someway to hard code something into the .php file of the calendar plugin so that my nav always displays? Or some conditional statement I can code into my header.php file to make sure that my nav appears on Event pages even if they are not included in the submenu structure?

Here are some links to view:
http://casbaa.thinkcreativeinc.com/wordpress/events/ (does appear)
http://casbaa.thinkcreativeinc.com/wordpress/events/list/ (doesn’t appear)

Thanks,

J
soujohnAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Jason C. LevineDon't talk to me.Commented:
Easiest way to do it is in header.php (where the menu functions most likely live).

1) Get the page IDs for the Event Calendar created pages (just hover on Edit in All Pages and write the ID numbers down)

2) Open header.php and look for references to the secondary menu...it should be right under the primary menu code.

3) Modify the code so it looks something like the following:

if ( is_page( array( 'xx','yy',zz' ) ) )
{
  if ( has_nav_menu( 'secondary' ) ) // or whatever the secondary Events menu is called
  { wp_nav_menu( array( 'theme_location' => 'secondary' ) ); } // or whatever the location is called
}

Open in new window

0
soujohnAuthor Commented:
Jason, thanks. I'll give this a try.
0
soujohnAuthor Commented:
Jason,
After quite a bit of trial-and-error I asked the original plugin creator, Christian Varga, who developed the sub menu feature I was trying to implement. Turns out that he developed a modified version of the plugin for forcing a submenu onto a page by referencing the menu item id from another page using the submenu you would like to duplicate.

Even though the code was provided; I still ran in to trouble trying to implement myself. And it turned out that I had a couple syntax issues (e.g., wrapping the root id in quotes when I wasn't supposed to & placing the full "menu-item-number" instead of just the actual number). After I figured that out the submenu displayed as I intended.

Here is the code that I used. I used an if/else statement that searched for a specific body class ('single-tribe_events'), and if the loaded page used that body class it would force display the submenu found on the Main Events page (which uses menu-item-id-389). Else it would display whatever submenu was created for that page.

<?php 
	$classes = get_body_class();
		if (in_array('single-tribe_events',$classes)) {
		wp_nav_menu( array( 'theme_location' => 'primary', 'sub_menu' => true, 'root_id' => 389	) );
	} else{
		wp_nav_menu( array( 'theme_location' => 'primary', 'sub_menu' => true, 'direct_parent' => true) );
	}
?>

Open in new window


Thanks for the help
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
soujohnAuthor Commented:
My comment links to a bit of modified code that was created specifically to solve the issue I was having. Anyone with a similar issue may find that link helpful.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
WordPress

From novice to tech pro — start learning today.