Custom search form in theme
-
Hi there,
My theme has a custom search form, for posts only. The structure is something like the first example here.
But the Theme Check plugin generates a warning:
WARNING: role=”search” was found in header.php. Use get_search_form() instead of hard coding forms. Otherwise, the form can not be filtered.So I’ve changed the search form into this:
<?php $native_search_form = get_search_form( false ); $custom_search_form = str_replace( '<input type="submit"', '<input type="hidden" name="post_type" value="post"><input type="submit"', $native_search_form ); echo $custom_search_form; ?>
Is this a proper way to hook into the default search form?
Guido
Viewing 5 replies - 1 through 5 (of 5 total)
Viewing 5 replies - 1 through 5 (of 5 total)
- The topic ‘Custom search form in theme’ is closed to new replies.