How to add a search box in WordPress menu?

How to add a search box in WordPress menu? Do not use and does not require any WordPress plugin. We want to achieve this effect simply follow the same steps. How to add WordPress menu search box: add WordPress menu search box to open the functions.php file, and copy and paste the following code snippet end of the file and save it. The following code will automatically add a search box to the main menu bar. / ** * Add searchbox in menubar * / add_filter ( 'wp_nav_menu_items',' add_search_box ', 10, 2);. Function add_search_box ($ items, $ args) {$ items ='   
      
  • ’ . get_search_form( false ) . ‘
  •   
  '; Return $ items;} default case, it will appear as the theme color combination, but if you want to change the style, you can add custom styles to the search box. In the example, I've added the margins of the search box at the top and to the right. .searchbox-position {margin-top: 15px; margin-right: 20px;}

Guess you like

Origin www.cnblogs.com/app3456789/p/11797695.html