Modify the WordPress search form to use Bootstrap components.

PHP April 26, 2017


This function runs automatically, so it is not called manually. Is this incorrect?

Source File

Located in /libs/Functions.php on line 1071.

    public function search_form($placeholder=''){
        $override = apply_filters('pre_nebula_search_form', false, $placeholder);
        if ( $override !== false ){echo $override; return;}

        $value = $placeholder;
        if ( empty($placeholder) ){
            $placeholder = 'Search';
            if ( get_search_query() ){
                $value = get_search_query();
                $placeholder = get_search_query();

        $form = '<form id="searchform" class="form-group form-inline ignore-form" role="search" method="get" action="' . home_url('/') . '">
                    <div class="input-group mb-2 mr-sm-2 mb-sm-0">
                        <div class="input-group-addon"><i class="fa fa-search"></i></div>
                        <label class="sr-only" for="s">Search</label>
                        <input id="s" class="form-control ignore-form" type="text" name="s" value="' . $value . '" placeholder="' . $placeholder . '" role="search" />

                    <button id="searchsubmit" class="btn btn-brand wp_search_submit" type="submit">Submit</button>

        return $form;


To override this PHP function, call the override filter (found in the first line of the function if it exists) in a hook.

add_filter('pre_nebula_whatever', 'my_custom_function_name');
function my_custom_function_name($parameter){
    //Write your own code here

You can completely disable this PHP function with a single line filter:

 add_filter('pre_nebula_whatever', '__return_false');