jamesdio
Forum Replies Created
Viewing 3 replies - 1 through 3 (of 3 total)
-
Forum: Plugins
In reply to: Different menus for logged usersOK. So I will answer for others…
First of all, edit functions.php and add this code:
function register_my_menus() { register_nav_menus( array( 'menu-footer' => __( 'Menu in the footer' ), ) ); } add_action( 'init', 'register_my_menus' );The code above registers new menu, name of the new menu is in my case: menu-footer
Next add these lines:
function my_wp_nav_menu_args( $args = '' ) { // Primary menu location if( 'primary' == $args['theme_location'] ) { if( is_user_logged_in() ) { $args['menu'] = 'logged-in-menu'; } else { $args['menu'] = 'logged-out-menu'; } return $args; } // Secondary menu location if( 'menu-footer' == $args['theme_location'] ) { if( is_user_logged_in() ) { $args['menu'] = 'menu-informacyjne'; } else { $args['menu'] = 'menu-informacyjne'; } return $args; } } add_filter( 'wp_nav_menu_args', 'my_wp_nav_menu_args' );The first menu (primary) is different for logged in/logged out users.
The second menu (menu-footer) is always visible for logged/non logged users.I edited one more file: footer.php in my theme folder and added this line:
<?php wp_nav_menu( array( 'theme_location' => 'menu-footer' ) ); // this is my menu-footer>Now everything works fine. All edited files are in child theme folder of course…
Forum: Plugins
In reply to: Different menus for logged usersAny idea?
Forum: Networking WordPress
In reply to: Multisite and theme settingsThanks for answer. Now I know.
Viewing 3 replies - 1 through 3 (of 3 total)