how to insert data in li tag of navigation

There are a few ways to do this and they mostly revolve around the walker_nav_menu_start_el filter. I’d be inclined to add custom fields to the nav menu items: one for the image and one for the image’s alternate text. That way, users can update the images and developers aren’t required to keep a hash of … Read more

Adding Additional Variables on Menus Page

Use the checked function. https://codex.wordpress.org/Function_Reference/checked The HTML you want to render should look like this: <input … value=”hide” checked=”checked” />Hide from these locations.</br> <input … value=”show” />Only show to these locations.</br> What you’re getting instead is probably somthing like this: <input … value=”hide” />Hide from these locations.</br> <input … value=”” />Only show to these locations.</br> … Read more

Nav menu from plugin to theme

wp_nav_menu() doesn’t accept a single value for a parameter, it takes an array. Proper format (if you are looking to simply call the menu by ID) would look like this: wp_nav_menu( array( ‘menu’ => $menu_id ) ); I’d recommend checking out the full reference in the codex for more information on the available parameters for … Read more

Multiple navigation menu in same location

Create multiple menus for each parent page and use an if condition to test which is the parent page and output that particular menu. You could keep the menu names the same as the parent page names so that any future pages created with new menus will still work. empty( $post->post_parent ) ? $post_parent_name = … Read more

Change link in menu on condition

One option to do this involves using the CSS display property. Simply add two instances of your menu link, one with the home URL and one with the URL for all other pages. The idea is to hide the one you don’t want on pages you want the other to show, never showing both on … Read more

How can I use custom menus with a Bootstrap WordPress theme?

You can change the classes of the <ul> by adding ‘menu_class’=>’nav navbar-nav’ to your $args array. Remember, this parameter overwrites all the classes, so add “menu” as well if you want many themes and plugins to work! If you don’t want the outer <div>, you can “unwrap” the <ul> by adding ‘container’=>false. $args = array( … Read more

How to request container_class from wp_nav_menu

Go with a custom Walker class Your_Walker_Nav_Menu extends Walker_Nav_Menu { var $container_class; public function __construct($container_class) { $this->container_class = $container_class; } function start_el( &$output, $item, $depth = 0, $args = array(), $id = 0 ) { global $wp_query; $indent = ( $depth > 0 ? str_repeat( “\t”, $depth ) : ” ); // code indent // … Read more