Skip to content

Instantly share code, notes, and snippets.

@zexeder
Created April 26, 2015 20:05
Show Gist options
  • Save zexeder/6b52b62f6b5e7994bd3e to your computer and use it in GitHub Desktop.
Save zexeder/6b52b62f6b5e7994bd3e to your computer and use it in GitHub Desktop.
Добавление поиска в меню WP
//Добавить в functions.php
add_filter( 'wp_nav_menu_items', 'add_search_box', 10 , 2);
function add_search_box ( $items, $args ) {
if( 'menu-index' === $args -> theme_location )
$items .= '<li class="custom-func-li-last">' . get_search_form(false) . '</li>';
return $items;
}
//menu-index - это название меню к которому будет добавлен элемент,
//получить его можно так же из файла functions.php:
register_nav_menus( array(
'menu-index' => 'Главное меню',
));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment