Dear,
I’ve been able to modify the default WordPress behavior in such way that all urls stated as “#” are redirected to a javascript code. Please check below the code :
add_filter('walker_nav_menu_start_el', 'wpse_226884_replace_hash', 999);
/**
* Replace # with js
* @param string $menu_item item HTML
* @return string item HTML
*/
function wpse_226884_replace_hash($menu_item) {
if (strpos($menu_item, 'href="#"') !== false) {
$menu_item = str_replace('href="#"', 'href="javascript:void(Tawk_API.toggle())"', $menu_item);
}
return $menu_item;
}
The redirection link itself is javascript:void(Tawk_API.toggle())
I need to do the same for Woodmart urls. Can you help me make the same for Woodmart?
Thanks for the help