how to set Primary Menu in wpmu automatically - wordpress

when we create sub domain in wpmu the we create four page home,about,team,and contact.
page is created successfully.
But how to select these pages on Primary Menu.

For this you can set menu name in header.php file and when you add that menu in given menu it automatically showing in wordpress
<?php wp_nav_menu(
array( 'menu' => 'primary', // menu name in wordpress
'menu_class' => 'nav-menu' ) );
?>
it is very simple and you need not to set again and agin just carefully you menu name is primary or header or whatever.

Related

Create dynamic menu in wordpress theme converting from html to wordpress

I have converted my one page html website to wordpress theme. Index.html page is converted to header.php, index.php and footer.php .
Now I want to make a dynamic menu. I have registered my menu in WordPress and it I showing in the admin panel. When I create a new menu now the page is showing to add my menu there. How can I create that page?
You may need to register the menu via functions.php.
If you dont have, create a file inside your theme as functions.php and paste the following code to register the menu.
register_nav_menus( array('my_nav' => __( 'Primary Navigation', 'dz theme' ),
'secondary' => __('Secondary Navigation', 'dz theme')
));
And you can call your primary menu as :
<?php wp_nav_menu( array( 'container_class' => 'menu-header', 'theme_location' => 'my_nav' ) ); ?>

Wordpress menu using hash tags for single page but not when I load blog template

I am creating a single page wordpress site. The primary menu that is in header.php uses hash links to reference content in the page. All the content in the body of the webpage loads into page-home.php. One of the items in my primary menu however is Blog. Blog loads entirely different templates. Once you are in blog, the other menu items do not work because the hash links no longer have the content in the index.php templates to connect to. Should I conditionally load a separate menu for when the url is /blog/? Call a separate header on index.php?
No need for two header.php files. Inside your current header.php use this code
<?php
if(is_page('Home'){ //or whatever your home page is called
wp_nav_menu ( $arrayName = array( 'theme_location' => 'primary', 'container' => 'nav', 'container_class' => 'navbar-collapse collapse', 'menu_class' => 'nav navbar-nav navbar-right' ) );
} else{
//INSERT CODE FOR BLOG MENU
}
?>

How to allow my theme to support multiple menus in wordpress

I am developing a site in Wordpress. I am using a theme named Moesia. While customizing the the theme according to my website needs, i found that the theme only supports one menu which is the main menu at the Top Right.
I want to add another menu which will only be visible inside a page. I have tried to add custom menu to a page, the issue that when I click on a menu item the whole page refreshes and the menu goes away. I want the menu to stay on that page and a click on the menu item should display the content adjacent to the menu.
I am absolutely new to this technology.
How can I achieve this?
Add the following to your functions.php file. The 2 menus are the “Primary”, and “Secondary” menus.
//Register Navigations
add_action( 'init', 'my_custom_menus' );
function my_custom_menus() {
register_nav_menus(
array(
'primary-menu' => __( 'Primary Menu' ),
'secondary-menu' => __( 'Secondary Menu' )
)
);
}
To add them to your site you need to add the following to your WordPress template files (most likely your header.php and footer.php files).
<?php wp_nav_menu (array('theme_location' => 'primary-menu','menu_class' => 'nav'));?>
<?php wp_nav_menu (array('theme_location' => 'secondary-menu','menu_class' => 'nav'));?>

How to list menu without submenu in WordPress

I need to list my menu in the bottom of my WordPress site without sub menu. I have tried this but this one lists menu with sub menus:
wp_nav_menu(array(
'container_class' => 'class_name',
'theme_location' => 'primary'
));
You want to add 'depth' => 1 to that array you're passing. See http://codex.wordpress.org/Function_Reference/wp_nav_menu
The code you used...
wp_nav_menu( array( 'container_class' => 'class_name', 'theme_location' => 'primary' ) );
shows the dynamic Menus of a site.
From your admin panel "Appearance » Menus", just enable a new custom menu on the Primary Menu location. And add the pages/posts on to the menu as the main menu. Don't nest any sub menu. It'll solve your problem.

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.

Resources