Hot answers tagged

2

If you are trying to get the post type for the current 'post', I think you could go with get_post_type(). Like this: $post_type = get_post_type(); Try it out.


2

Solution 1: Using customize walker I got some idea from add span class inside wp_nav_menu link anchor tag and make some change as your requirement. 1. Add this code below to your functions.php first. class Nav_Walker_Nav_Menu extends Walker_Nav_Menu{ function start_el(&$output, $item, $depth, $args){ global $wp_query; $indent = ( ...


2

Please Try with bellow : wp_nav_menu( array( 'theme_location' => 'header_menu', 'container_id' => 'menu', 'walker' => new description_walker() ) ); And Add functions.php class description_walker extends Walker_Nav_Menu{ function start_el(&$output, $item, $depth, $args){ global $wp_query; $indent = ( $depth ) ? ...


1

There are a few ways to do this and they mostly revolve around the walker_nav_menu_start_el filter. I'd be inclined to add custom fields to the nav menu items: one for the image and one for the image's alternate text. That way, users can update the images and developers aren't required to keep a hash of all menu items and related image URLs/alt text in code ...



Only top voted, non community-wiki answers of a minimum length are eligible