Dropdown menu on the nav bar does not work

Hi,

I added this code to display the list of some people registered in the site, in the Menu bar but somehow the list does not show, it just shows the main link but not the dropdown list. Please advise.

The code is not displaying properly please suggest how to show you the code.

Thank you

Hi,

You can try this code instead.

add_filter( 'wp_nav_menu_items', 'wcv_vendors_menu', 10, 2 );
function wcv_vendors_menu ( $items, $args ) {
   	if ($args->theme_location == 'primary') {
		$vendors  = get_users( array( 'role' => 'vendor' ) ); 
		$items .= '<li class="menu-item  menu-item-has-children"><a href="#">Vendors</a>'; 
		$items .= '<ul class="sub-menu">'; 
		foreach( $vendors as $vendor ) { 
			$vendor_shop_link = site_url( WC_Vendors::$pv_options->get_option( 'vendor_shop_permalink' ) .$vendor->pv_shop_slug ); 
			$items .= '<li><a href="'.$vendor_shop_link.'">'.$vendor->pv_shop_name.'</a></li>';
		}
		$items .= '</ul></li>'; 
   	}
    return $items;
}

Hope that helps.

It did help Paul, Thank you so much.

You’re welcome! :slight_smile: