Skip to Content
Menu

redirect_empty_search()

Prevent empty search query error page.

PHP April 27, 2017

Usage

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

Was this page helpful? Yes No


    A feedback message is required to submit this form.


    Please check that you have entered a valid email address.

    Enter your email address if you would like a response.

    Thank you for your feedback!

    Source File

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

    No Hooks

    This function does not have any filters or actions available. Request one?
    PHP
            public function redirect_empty_search($query){
                global $wp_query;
                if ( isset($this->super->get['s']) && $wp_query->query && !array_key_exists('invalid', $this->super->get) ){
                    if ( $this->super->get['s'] == '' && $wp_query->query['s'] == '' && !$this->is_admin_page() ){
                        header('Location: ' . home_url('/') . 'search/?invalid'); //Why not wp_redirect() here?
                        exit;
                    } else {
                        return $query;
                    }
                }
            }
    

    Override

    This function can not be short-circuited with an override filter. Request one?