Quantcast
Channel: WordPress › Support » Forum: Hacks - Recent Topics
Viewing all articles
Browse latest Browse all 8245

shanebp on "wp_nav_menu_items - mobile problem"

$
0
0

I'm using the wp_nav_menu_items filter hook to add a subnav to the main navigation for this site: http://www.newspebbles.com
It uses a child theme for 2013

function new_nav_menu_items($items) {
	global $wpdb; 

	$localities_links = '';

	$query = //etc
	$localities = //etc

	if( $localities ) {	

	    foreach( $localities AS $locality ) {

		$localities_links .= '<li id="menu-item" class="menu-item menu-item-type-post_type menu-item-object-page"><a href="http://www.newspebbles.com/' . $locality->locality_slug . '/">' . $locality->locality_name . '</a></li>';	

	    }

	    $items = str_replace('<a>Localities</a></li>', '<a>Localities</a><ul class="sub-menu">'.$localities_links.'</ul></li>', $items);
	}

    return $items;
}
add_filter( 'wp_nav_menu_items', 'new_nav_menu_items' );

The 'Localities' link ( and all the other links ) was created via Appearance > Menus.
This works properly on laptops.
But on mobile devices the links do not work.
On iOS, the 'Localities' link does not work.
On Android, the 'Localities' link shows the subnav, but the subnav links do not work.

What is the recommended solution re main nav on mobile?
Will I have to use wp_nav_menu to create the whole nav menu via code?
And / or a custom walker?


Viewing all articles
Browse latest Browse all 8245

Trending Articles