Search box as a menu item in the nav menu output by wp_nav_menu?

based on : http://wpfirstaid.com/2010/10/extend-the-wordpress-menu/ function wpa_58902($items){ $search=”<li class=”search”>”; $search .= ‘<form method=”get” id=”searchform” action=”https://wordpress.stackexchange.com/”>’; $search .= ‘<label for=”s” class=”assistive-text”>Search</label>’; $search .= ‘<input type=”text” class=”field” name=”s” id=”s” placeholder=”Search” />’; $search .= ‘<input type=”submit” class=”submit” name=”submit” id=”searchsubmit” value=”Search” />’; $search .= ‘</form>’; $search .= ‘</li>’; return $items . $search; } add_filter(‘wp_nav_menu_items’,’wpa_58902′);

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

Move WP Admin Bar

The admin bar is hooked to wp_footer. So … remove_action( ‘wp_footer’, ‘wp_admin_bar_render’, 0 ); … will remove it from there. And then you can register it for a custom hook with: add_action( ‘my_custom_hook’, ‘wp_admin_bar_render’, 1000 ); You still have to overwrite the CSS in your stylesheet, but that should be fairly simple. Oh, and welcome … Read more

wp_nav_menu doesn’t generate parent/ancestor classes

This is part of code in _wp_menu_item_classes_by_context() that handles current class for pages: // if the menu item corresponds to the currently-queried post or taxonomy object } elseif ( $menu_item->object_id == $queried_object_id && ( ( ! empty( $home_page_id ) && ‘post_type’ == $menu_item->type && $wp_query->is_home && $home_page_id == $menu_item->object_id ) || ( ‘post_type’ == $menu_item->type … Read more

Number of items in a menu

I was curious and decided to check it out, regardless if it’s relevant for a CSS problem 😉 I first peeked into the database tables to find more about the menu structure: Menu – building blocks Each navigational menu is registered as a term in the nav_menu taxonomy. Then when we add items to that … Read more

Adding different classes to anchor in navigation menu

Yes, it is possible. You can achieve this using wp_nav_menu_objects filter. function my_wp_nav_menu_objects($objects, $args) { foreach($objects as $key => $item) { $objects[$key]->classes[] = ‘my-class’; } return $objects; } add_filter(‘wp_nav_menu_objects’, ‘my_wp_nav_menu_objects’, 10, 2); The only problem is that these classes will be added to li elements and not to links directly. But it’s default WordPress behavior … Read more

Generate a tabbed submenu — from taxonomy term or submenu item — with sample content

I ended up solving this problem with Ubermenu. What I wanted to write was complex enough that it made more sense to get a tested, commercial plugin that had the features I need. MaxMegaMenu didn’t do tabbed content but Ubermenu does. I’m able to construct menus like this: Taxonomy1 [Tabs] [DynamicTerms] [Dynamic Posts] Taxonomy2 [Tabs] … Read more

Displaying wp menus by name without using theme locations

Umm u can do that easily. And this is the way I do how i register my menu in functions.php add_action(‘init’, ‘register_custom_menu’); function register_custom_menu() { register_nav_menu(‘custom_menu’, __(‘Custom Menu’)); } Then in ur admin panel u create different menu by ur desired name. And get the menu where ever u want like this. EX:- if I … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)