I use wp_is_mobile() conditional tag to show different menu items on mobile via “Menu Items Visibility Control” plugin.
I realized wp_is_mobile() conditional tag is not working after some time on my website.
Whenever I deactivate Event Organizer Pro it works again.
Any idea how I can use both plugins simultaneously?
Adnan Akbas
Hi Adnan,
Can you confirm that the problem is with wp_is_mobile()
specifically (print outs its return value, and var_dum($_SERVER)
– (we are particularly interested in $_SERVER['HTTP_USER_AGENT']
).
In short wp_is_mobile()
does nothing but check the value of $_SERVER['HTTP_USER_AGENT']
(See source) and Event Organiser (Pro) does nothing to that value, so I don’t think Event Organiser Pro – by itself – can be causing wp_is_moble()
to return an incorrect value.
More plausible is that Pro and Menu Items Visibility Control are conflicting in some other way.
Stephen Harris
Hi Stephen,
thanks for your quick answer. Instead of using the plugin, I added my own code like:
if(wp_is_mobile() && $args->theme_location == 'primary') {
$items .= ...my-menu-item....
return $items;
} else {
return $items;
}
}
add_filter( 'wp_nav_menu_items', 'add_mobile_nav', 10, 2 );
which works fine. That means you are right. wp_is_mobile() is not the problem.
Should be something else. Job is done. Thank you!
Adnan Akbas
Glad you’ve found something that works for you.
Stephen Harris