Ask your WordPress questions! Pay money and get answers fast! Comodo Trusted Site Seal
Official PayPal Seal

Separate Main Menus on a per-page basis * Karma Theme WordPress

I am trying to have separate Main Navigation Menus on a per page-basis.

Product: Karma - Wordpress Theme
Website URL: http://www.ivorytc.com/wordpress/home-us

I need to have two main menus; for two seperate areas of a site I am building for a client, http://ivorytc.com/wordpress; one is for US based clients (http://www.ivorytc.com/wordpress/home-us). And, one for Non-US based clients (http://ivorytc.com/wordpress/itc-home-non-us).

I would like to use the menu I built in my custom menus called "US Menu" as the main menu in the following pages, 5740,5678,5748,5603,5645,5717,5704,5726,5744,5656,5746,5800,5825, and 5827. And, I am told by the Karma Theme support team...

"Hello again,

We have already mentioned that it is not possible to have separate Main Navigation on a per page-basis. This is not a theme issue, you just need to engage a programmer to customize a solution for you. As we also mentioned, you can easily find a very affordable and knowledgeable programmer at wpquestions.com.

Cheers".

So, here I am... Please, help me!

Frustrated Website Builder

Answers (4)

2011-11-16

Luis Abarca answers:

You can try this, create 2 menus in your admin area.

Then have a default menu and only show the no-us in a particular page.



$menu = 'menu-us';

if ( is_page('itc-home-non-us') ) :
$menu = 'menu-no-us';
endif;

wp_nav_menu( array( 'menu' => $menu ) );



Top Shelf comments:

Where would I put the code you gave me, on a particular page?


Luis Abarca comments:

Hi Dane,

I think you want to change the left menu isn't it ? So you can put it in the sidebar.php


Top Shelf comments:

No Sir,

I need to change the main menu which appears horizontally near the top of the page(s).


Luis Abarca comments:

Ok, so you should look for wp_nav_menu in your header.php and replace your current menu

2011-11-16

Clifford P answers:

If you only want to have "if page x, show 1st menu, else show 2nd menu", you can do that... let me know if it's as stright forward as that.


Top Shelf comments:

Yes it is that simple.


Clifford P comments:

If you need help doing it for you, PM a login to your WP. Else, you can find it in your theme file and do as others have advised.

2011-11-16

Pixel Coder answers:

Hello Dane,

If you are familiar with custom fields you could use them to allocate in a slightly more dynamic way a menu to page.

Create a custom field called "menu-to-show" or similar.

Within your theme file navigate to page.php and find where you currently call the menu from.

Replace the wp_nav_menu(); call with the following.

[code]
$db_menu = get_post_meta($post->ID, 'menu-to-show', true);
[/code]

This should now allow you to call any custom nav menu you have on any page simply by filling out the custom field to match your menu.

Also if you're getting no return on the menu after implementing add this line just before.

[code]
the_post();
$db_menu = get_post_meta($post->ID, 'menu-to-show', true);
[/code]

Let me know how you get on.

Cheers.


Top Shelf comments:

Alistair,

Thank you for your detailed explanation; however, it appears my theme does not contain the wp_nav_menu(); call within page.php

If you would like to confirm this you can gain access via

http://www.ivorytc.com/wordpress/wp-admin

Usn: ITCAdmin
Pass: kill1849


Pixel Coder comments:

hello mate, i can do this for you if you give me 15 minutes please?

also you should remove your username and password here. that's very very public, you should also change it and send via a private message.


Pixel Coder comments:

Hello, it might be located within sidebar.php or another file being called from page.php.

Really follow the breadcrumbs and you should find what you are looking for.


Pixel Coder comments:

Hey Dane after a little playing and poking all seems fine and stress tested.

To add a specific menu to a specific page please use the custom field

"px-menu-to-show" and the value would be an exact copy of the menu name you would like displayed on that page.

You can grab the exact name from the menus page.

If the menu doesn't match the criteria (e.g. a menu with that name does not exist) it falls back to the previous function (e.g. the menus that were being displayed before this work was completed).

Hope that helps.


Top Shelf comments:

Hello Alistair,

I appreciate the assistance. The menu I am speaking about it the is menu-main-nav. I believe what you've edited was the sidebar. Is something able to be done with the menu-main-nav?

Dane


Pixel Coder comments:

Oh, nightmare. Let me sort that out now.

To confirm the main menu is the top bar?