Change image based on menu item id

If your header image is a background image, you can change it with CSS on every page thanks to body_class(); Your <body> tag should look like this : <body <?php body_class(); ?> > Then when you visit each page you’ll notice in the code that various classes are added to the body tag. You can … Read more

Customizing a walker menu class

I think Your looking for the solution : http://shinraholdings.com/62/custom-nav-menu-walker-function/ Add this code where you calling your WP menu. wp_nav_menu( array( ‘theme_location’ => ‘navigation_menu_primary’, ‘container’ => ‘div’, ‘container_id’ => ‘top-navigation-primary’, ‘conatiner_class’ => ‘top-navigation’, ‘menu_class’ => ‘menu main-menu menu-depth-0 menu-even’, ‘echo’ => true, ‘items_wrap’ => ‘%3$s’, ‘depth’ => 10, ‘walker’ => new themeslug_walker_nav_menu ) ); // thanks … Read more

How to retrieve depth of menu into template

how to get the relation between the page and the menu item ? = is there a WP function telling this page is linked to this menu item which has or hasn’t a parent Inside the walker, inside the start_el method (which you mentioned), $item->object_id is the page ID. Otherwise, you need to pull the … Read more

custom menu not found

I’m not sure if I’ve followed you correctly; but I think you’re trying to build the Menu HTML entirely on your own. If I’m correct, then what you’re trying to do is covered under “Walker” object of wp-nav-menu. You need to write a separate function in your functions.php and then pass the function name as … Read more

Get menu item slug

Well you’ve Post ID with you. So you can use this custom function to retrieve slug of any post. function get_the_slug( $id=null ){ if( empty($id) ): global $post; if( empty($post) ) return ”; // No global $post var available. $id = $post->ID; endif; $slug = basename( get_permalink($id) ); return $slug; } This in return will … Read more