WordPress Add javascript:void(0); to menu link item?

I am not sure how it does effect the SEO but just to answer this question:- You can not save menu item with javascript:void(0); because WordPress filter the URL using function esc_url() thus removing bad values. And it all happens in Nav Walker class. So you need to alter the URL when WordPress done with … Read more

Remove nav_menus from customizer using a theme

This is panel not section so remove_section() will not work in this case. However you can use function remove_panel() but it will trigger a notice saying Notice: WP_Customize_Manager::remove_panel was called incorrectly Removing nav_menus manually will cause PHP warnings. Use the customize_loaded_components filter instead. Please see Debugging in WordPress for more information. (This message was added … Read more

Nav walker, bootstrap: Display 3rd level items under 2nd level

I solved this problem. follow these instructions….. Add script (function($){ $(document).ready(function(){ $(‘ul.dropdown-menu [data-toggle=dropdown]’).on(‘click’, function(event) { event.preventDefault(); event.stopPropagation(); $(this).parent().siblings().removeClass(‘open’); $(this).parent().toggleClass(‘open’); }); }); })(jQuery); 2.Remove && $depth === 0 from this line: if ( $args->has_children && $depth === 0 ) in wp_bootstrap_navwalker.php file. See the screenshot here.

How to add text before WordPress menu item href

A Custom Walker would be the best way to add anything anywhere to your wp_nav_menu You hav to keep the following in your function.php <?php class MV_Cleaner_Walker_Nav_Menu extends Walker { var $tree_type = array( ‘post_type’, ‘taxonomy’, ‘custom’ ); var $db_fields = array( ‘parent’ => ‘menu_item_parent’, ‘id’ => ‘db_id’ ); function start_lvl(&$output, $depth) { $indent = … Read more

Add Bootstrap dropdown class to a nav menu

The easiest way to do this is to use an off-the-shelf solution. There is a WP_Bootstrap_Navwalker class which extends WordPress’ native Walker_Nav_Menu class and makes your Navigation Menus ready for Bootstrap 3 or 4. Download it from GitHub. Add it to your theme, then add the following to the functions.php: <?php require_once(‘path-to-the-directory/wp-bootstrap-navwalker.php’); Change path-to-the-directory/ to … Read more

add_action for saving a custom menu

At least in 3.4.1, there is an action for that: wp_update_nav_menu See here. Then you can get the items in your menu with something like: add_action(‘wp_update_nav_menu’, ‘my_get_menu_items’); function my_get_menu_items($nav_menu_selected_id) { $items = wp_get_nav_menu_items($nav_menu_selected_id); }

Add within the output of

According to the Codex, wp_nav_menu() has a couple parameters to add HTML or entities before and after the generated HTML. The parameters you want is link_before and link_after and to get the effect you’re after looks like this: ‘link_before’ => ‘<span class=”left_arrow”></span><span class=”middle_text”>’, ‘link_after’ => ‘</span><span class=”right_arrow”></span>’