I have already asked a similar question at stackoverflow (https://stackoverflow.com/questions/22492292/add-filter-in-wordpress-how-do-i-know-if-it-is-run), but maybe that was the wrong place?
As you can see there I am trying to add a search box in the way I have seen recommended:
add_filter('wp_nav_menu_items','menu_search');
function menu_search($items){
$search = '<li class="search">';
$search .= '<form method="get" id="searchform" action="/">';
$search .= '<input type="text" class="field" name="s" id="s" placeholder="Search" />';
$search .= '</form>';
$search .= '</li>';
return $items . $search;
}
However I see no trace of the search box in the menu. In fact it looks like the code added to add_filter is not even run.
There are a couple of things I do not know here. I am doing this in a new theme, based on the underscore theme (see http://underscores.me/) since I needed a really light weight theme. I am starting to wonder if the code for filtering is run in the underscore theme. What is the best way to check that? (I do not know php debugging at all. I just added Debug Bar etc.) And did I miss something in the underscore theme here? I mean should I have added anything for it to run the filtering?