Return to Snippet

Revision: 61440
at December 13, 2012 04:03 by hell0world


Initial Code
<?php

// add the following to wp theme function.php
	register_nav_menus( array(
		'primary-menu' => 'main menu',
                'marketing-menu' => 'marketing menu',
                'shopping menu' => 'shopping menu',
		'technology menu' =>  'technology menu',
		'recreation menu' =>  'recreation menu',
	) );

add_action( 'init', 'register_nav_menus' );
?>

<?php
// add following to where you want the menu share, in my case, hearder.php
<?php
			if((has_nav_menu('marketing-menu') and !is_home() and is_category(array(5,6,8,9,10,11,12,13,14))) or (has_nav_menu('marketing-menu') and !is_home() and in_category(array(5,6,8,9,10,11,12,13,14))))  {
					wp_nav_menu(array(
					'theme_location' => 'marketing-menu',
					'container' => '',
					'menu_id' => 'primary-nav',
					'container_class' => 'main-menu',
					'menu_class' => 'nav'
				 ));
			}
			else(has_nav_menu('primary-menu')){
				 wp_nav_menu(array(
					'theme_location' => 'primary-menu',
					'container' => '',
					'menu_id' => 'primary-nav',
					'container_class' => 'main-menu',
					'menu_class' => 'nav'
				 ));

?>

Initial URL

                                

Initial Description
[register_nav_menus](http://codex.wordpress.org/Function_Reference/register_nav_menus,"register_nav_menus")
[wp_nav_menu](http://codex.wordpress.org/Function_Reference/wp_nav_menu,"wp_nav_menu")
[in_category](http://codex.wordpress.org/Function_Reference/in_category,"in_category")
[is_category](http://codex.wordpress.org/Function_Reference/is_category,"is_category")

Initial Title
Wordpress Custom Menu For Different Category/Page/Post

Initial Tags
wordpress, category

Initial Language
PHP