wp_nav_menu log in/out link?
Use the wp_nav_menu_items hook to add a filter which will allow you to add your login / logout link. Use wp_loginout() to display a status aware login / logout link. Codex page.
Use the wp_nav_menu_items hook to add a filter which will allow you to add your login / logout link. Use wp_loginout() to display a status aware login / logout link. Codex page.
Yes, it is possible. You can achieve this using wp_nav_menu_objects filter. function my_wp_nav_menu_objects($objects, $args) { foreach($objects as $key => $item) { $objects[$key]->classes[] = ‘my-class’; } return $objects; } add_filter(‘wp_nav_menu_objects’, ‘my_wp_nav_menu_objects’, 10, 2); The only problem is that these classes will be added to li elements and not to links directly. But it’s default WordPress behavior … Read more
just been reading an article on removing <li> elements from wp_nav_menu (http://css-tricks.com/snippets/wordpress/remove-li-elements-from-output-of-wp_nav_menu/) and the code suggested is $menuParameters = array( ‘container’ => false, ‘echo’ => false, ‘items_wrap’ => ‘%3$s’, ‘depth’ => 0, ); echo strip_tags(wp_nav_menu( $menuParameters ), ‘<a>’ ); have you tried this ?
Define two menus and serve them based on if they are logged in or not which you can do in your theme’s functions.php file: if (is_user_logged_in()){ wp_nav_menu( array( ‘menu’ => ‘Logged In Menu’, ‘container_class’ => ‘logged-in-menu’, ‘theme_location’ => ‘logged-in’ )); } else { wp_nav_menu( array( ‘menu’ => ‘Visitor Menu’, ‘container_class’ => ‘visitor-menu’, ‘theme_location’ => ‘visitor’ … Read more
<?php if (!function_exists(‘debug_admin_menus’)): function debug_admin_menus() { global $submenu, $menu, $pagenow; if ( current_user_can(‘manage_options’) ) { // ONLY DO THIS FOR ADMIN if( $pagenow == ‘index.php’ ) { // PRINTS ON DASHBOARD echo ‘<pre>’; print_r( $menu ); echo ‘</pre>’; // TOP LEVEL MENUS echo ‘<pre>’; print_r( $submenu ); echo ‘</pre>’; // SUBMENUS } } } add_action( … Read more
In your template you can check whether you’re on the front-page or not and then echo out a different menu. For example: if(is_front_page() || is_home()){ wp_nav_menu(array(‘theme_location’ => ‘primary_navigation’)); }else{ wp_nav_menu(array(‘theme_location’ => ‘secondary_navigation’)); } You would also have to register a second menu locations in the functions.php file (if it hasn’t been done yet). To register … Read more
If you dont mind using a plugin I can tell you how I have gotten this to work in the past. Add the following code to your functions.php function get_root_parent($page_id) { global $wpdb; $parent = $wpdb->get_var(“SELECT post_parent FROM $wpdb->posts WHERE post_type=”page” AND ID = ‘$page_id'”); if ($parent == 0) return $page_id; else return get_root_parent($parent); } … Read more
There are probably several solutions to this, but this is what I would do: First set a static front page. This can be done in Settings->Reading. This will cause the menu item (page) selected to have the CSS class current-menu-item and also to display any sub-menu items you have. Then you just CSS them to … Read more
wp_nav_menu custom walker – child items
Well an easy solution is CSS <!– HIDES MENU ITEM IF THE USER IS NOT LOGGED IN –> <?php if (is_user_logged_in()){ echo “”;} else { echo “<style type=”text/css”> .menu-item-58 {display:none;} </style>”; }; ?> But if you are trying to code it down see the source of this plugin http://wordpress.org/extend/plugins/if-menu/ — it will help you alot. … Read more