Menu navigation wordpress - wordpress

I´m working on a wordpress site with 2 diffrent sections (landingpage that link to private or corporate). The sections have diffrent menu navigation buttons. Do I have to install 2 separate wp-installations or is there any better way to solve the navigation issue?

You don't have to install wordpress twice. To present some menu you can use
wp_nav_menu() function (see: http://codex.wordpress.org/Function_Reference/wp_nav_menu).
So in different files of your theme you can use:
<?php wp_nav_menu( array('menu' => 'menu1' )); ?>
and
<?php wp_nav_menu( array('menu' => 'menu2' )); ?>
Than, you have to create 2 menu1 and menu2 in the Appearance → Menus panel.

Related

Submenu not showing wordpress

My submenu is not displaying. I've tried all the possible wp_nav_menu php, but I just can't get my submenu to show up.
<?php wp_nav_menu( array('menu' => 'navigation' )); ?>
And you have checked your CSS? Most of the time it's just a display:none-problem.

Attach a specific menu to a specific page

In my Wordpress website:
I have two pages, one is in Deutsch and one is in English.
I have two menus, same deal.
I would like to display the english menu when browsing the page in English and display the deutsch menu when browsing the page in Deutsch.
I cannot use any multilingual pluging unfortunately.
Is there any way to achieve this with a basic wordpress installation?
Why can't you use a multi-language plugin?
Assuming you're right about the idea of not being able to use such a plugin, two solutions come to mind:
Use custom fields and conditional logic to display one menu or another
Use page templates to display different menus
You can override the layout of a page by creating a file called page-{slug}.php or page-{id}.php, in which {slug} and {id} should be substituted for the slug or id of the page you wish to make a template for. In this page template you could copy the original layout, but alter the wp_nav_menu command to select a different menu.
There are a few other ways to do it, but those two seem like sensible options to me.
Try this one:
Put this code in header.php while calling navigation menu:
<?php if (is_front_page()) { ?>
<div id='frontPageBanner'>
<?php wp_nav_menu( array( 'container_class' => 'menu-header-1', 'theme_location' => 'primary' ) ); ?>
</div>
<?php } elseif (is_archive()) { ?>
<div id='archiveBanner'>
<?php wp_nav_menu( array( 'container_class' => 'menu-header-2', 'theme_location' => 'primary' ) ); ?>
</div>
<?php } elseif ( is_page($pageID)) { ?>
<div id='pageIdBanner'>
<?php wp_nav_menu( array( 'container_class' => 'menu-header-1', 'theme_location' => 'primary' ) ); ?>
</div>
<?php } ?>
Thanks.

WP - how to create menus

Could you please explain me how do I properly create wordpress menus? I just want two menus on my website - with pages, and the other one with categories (by default).
Should I put html code for these menus in two separate files? Or rather put all id's in the array parameter of wp_nav_menu()? Tried the first one but the separate file nav-something.php doesn't seem to be loading ('theme_location' => 'nav-something').
If I want to display categories in the menu, should I simply use wp_list_categories()? Will user be able to change this in the future from admin interface?
Firstly You have to create the both menus under Appearance > Menu
Add below code where you want to show on the page. But you need to select the one menu as a primary menu in admin section. You can do this in Appearance > Menu > Primary Navigation
<?php wp_nav_menu( array( 'theme_location' => 'primary' ) ); ?>
For your category menu add new menu in admin section under Appearance > Menu and give the name "Category Menu" and paste the below code where you want to show this menu. After that you need to add the categories in menu section. You can enable category listing in wordpress screen option(Right top section in admin panel.)
<?php wp_nav_menu( array( 'theme_location' => 'primary', 'menu_class' => 'nav-menu', 'menu' => 'Category Menu' ) ); ?>
Please note down I have given the same name in above code and in admin section "Category Menu". You can add more menus by adding above code but you just need to give the same name in code and in WordPress admin section.
If you Don't want to create category menu in admin section then you can add this code in you file.
<?php wp_list_categories(); ?>
You have both the options now its on you which one you want to use.

How do I get second level menu in Wordpress?

I'm over 2 hours trying many functions (wp_list_pages, get_pages, wp_nav_menu) and several functions but can't resolve this thing out.
I have created pages that are THREE level deep:
PAGE level1
SUBPAGE level2
SUBPAGE level3
and I need to display a separate menu for each of them like:
MENU1 (all top-level pages)
MENU2 (all sub-pages of CURRENT top level page)
MENU3 (all sub pages of current item from MENU2)
it should not be that complicated for a CMS like Wordpress but I think I'm over-complicating possible solutions.
Do you have some suggestions on possible ways to achieve that?
Thanks.
First of all you have to define accordance between menu items and pages. I can't define this accordance from your question. What if you have two level2 subpages and two menu2 items? Which menu item belongs to which subpage?
Then the process is trivial. You can get all menu items
$menu_items = wp_get_nav_menu_items($cur_menu, array());
And check menu_item_parent field to found parent items
foreach ($menu_items as $item) {
if ($item->menu_item_parent === $parent_id) {
//this is child of $parent_id
}
}
If you are using the the WordPress Function register_nav_menus() , it should be fairly simple.
In your functions.php file you'll need to register 3 separate menu's, something like this:
<?php
add_action( 'init', 'register_my_menus' );
function register_my_menus() {
register_nav_menus(
array( 'first' => 'first', 'second' => 'second', 'third' => 'third', )
);
}
?>
With the menu's now registered you just need to place them where they go in your theme files like so:
The First Menu (maybe in the header.php file)
<div id="menu">
<?php wp_nav_menu( array( 'theme_location' => 'first' ) ); ?>
</div>
The Second Menu (maybe in the sidebar.php file)
<div id="menu">
<?php wp_nav_menu( array( 'theme_location' => 'second' ) ); ?>
</div>
The Third Menu (maybe in the footer.php file)
<div id="menu">
<?php wp_nav_menu( array( 'theme_location' => 'third' ) ); ?>
</div>
The final step is to go to Appearance>Menu's and create the 3 menu's, name them and choose the pages that will go with them from within the Admin Menu Settings.

Add Submenu in sidebar on wordpress

i would like to show the submenu of my page in a custom page template on the left side in a Sidebar-area. Does any know the code for showing the submenu.
I'm using Wordpress 3.4.1.
Register Menus
Firstly, in your theme's functions.php, you need to write a function to register the names of your menus.
function register_my_menus() {
register_nav_menus(
array( 'sidebar-menu' => __( 'Sidebar Menu' ) )
);
}
add_action( 'init', 'register_my_menus' );
Display Menus on Theme
Once you've done that, your theme will be almost ready. The last preparation step is to tell the theme where you want the menus to show up.
<?php wp_nav_menu( array( 'theme_location' => 'sidebar-menu' ) ); ?>
That's all the background work. To finish, you would simply visit the Appearance -> Menus panel in your site admin.
Please read the wordpress codex site.. it has plenty of information on how to do this..
http://codex.wordpress.org/Navigation_Menus

Resources