Adding different classes to anchor in navigation menu

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

How to remove trailing tags from wp_nav_menu walker

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 ?

change front end menu depending on user login

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

How can I get an array/list of all current WordPress Admin Menu items?

<?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

Change menu items URL

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

Navigation menu with children shown only for current page

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

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)