Skip to content

Snippet: Insert Search Form into the Page Header Title Area

This code will insert a searchform into the default theme's page header title area (where the title and breadcrumbs normally are located). The search form will be inserted after the title and breadcrumbs. You can then use a little CSS to position it as wanted.

add_action( 'wpex_hook_page_header_inner', function() {
	echo '<div class="my-page-header-search">' . get_search_form( array( 'echo' => false ) ) . '</div>';
}, 20 );
All PHP snippets should be added via child theme's functions.php file or via a plugin. We recommend Code Snippets (100% Free) or WPCode (sponsored)
Back To Top