Title: WP_Query::is_search
Published: April 25, 2014
Last modified: May 20, 2026

---

# WP_Query::is_search(): bool

## In this article

 * [Return](https://developer.wordpress.org/reference/classes/wp_query/is_search/?output_format=md#return)
 * [Source](https://developer.wordpress.org/reference/classes/wp_query/is_search/?output_format=md#source)
 * [Related](https://developer.wordpress.org/reference/classes/wp_query/is_search/?output_format=md#related)
 * [Changelog](https://developer.wordpress.org/reference/classes/wp_query/is_search/?output_format=md#changelog)
 * [User Contributed Notes](https://developer.wordpress.org/reference/classes/wp_query/is_search/?output_format=md#user-contributed-notes)

[ Back to top](https://developer.wordpress.org/reference/classes/wp_query/is_search/?output_format=md#wp--skip-link--target)

Determines whether the query is for a search.

## 󠀁[Return](https://developer.wordpress.org/reference/classes/wp_query/is_search/?output_format=md#return)󠁿

 bool Whether the query is for a search.

## 󠀁[Source](https://developer.wordpress.org/reference/classes/wp_query/is_search/?output_format=md#source)󠁿

    ```php
    public function is_search() {
    	return (bool) $this->is_search;
    }
    ```

[View all references](https://developer.wordpress.org/reference/files/wp-includes/class-wp-query.php/)
[View on Trac](https://core.trac.wordpress.org/browser/tags/7.0/src/wp-includes/class-wp-query.php#L4644)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/7.0/src/wp-includes/class-wp-query.php#L4644-L4646)

## 󠀁[Related](https://developer.wordpress.org/reference/classes/wp_query/is_search/?output_format=md#related)󠁿

| Used by | Description | 
| [is_search()](https://developer.wordpress.org/reference/functions/is_search/)`wp-includes/query.php` |

Determines whether the query is for a search.

  |

## 󠀁[Changelog](https://developer.wordpress.org/reference/classes/wp_query/is_search/?output_format=md#changelog)󠁿

| Version | Description | 
| [3.1.0](https://developer.wordpress.org/reference/since/3.1.0/) | Introduced. |

## 󠀁[User Contributed Notes](https://developer.wordpress.org/reference/classes/wp_query/is_search/?output_format=md#user-contributed-notes)󠁿

 1.  [Skip to note 2 content](https://developer.wordpress.org/reference/classes/wp_query/is_search/?output_format=md#comment-content-5026)
 2.   [lazhar007](https://profiles.wordpress.org/lazhar007/)  [  5 years ago  ](https://developer.wordpress.org/reference/classes/wp_query/is_search/#comment-5026)
 3. [You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Fclasses%2Fwp_query%2Fis_search%2F%23comment-5026)
    Vote results for this note: 0[You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Fclasses%2Fwp_query%2Fis_search%2F%23comment-5026)
 4.     ```php
        /**
         * INCLUDE CUSTOM POST TYPES IN SEARCH RESULTS
         */
        function wpdocs_cpt_in_search( $query ) {
            if ( ! is_admin() && $query->is_main_query() ) {
                if ( $query->is_search ) {
                    $query->set( 'post_type', array( 'convention' ) );
                }
            }
        }
    
        add_action( 'pre_get_posts', 'wpdocs_cpt_in_search' );
        ```
    
 5.  * This is not ideal, as it will override existing post types being searched. Better
       option is to adjust [the `exclude_from_search` parameter](https://developer.wordpress.org/reference/functions/register_post_type/#exclude_from_search)
       when registering the post type or via [the `register_post_type_args` filter](https://developer.wordpress.org/reference/classes/wp_post_type/set_props/).
     * [crstauf](https://profiles.wordpress.org/crstauf/) [5 years ago](https://developer.wordpress.org/reference/classes/wp_query/is_search/#comment-5029)
 6.  [Log in to add feedback](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Fclasses%2Fwp_query%2Fis_search%2F%3Freplytocom%3D5026%23feedback-editor-5026)

You must [log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Fclasses%2Fwp_query%2Fis_search%2F)
before being able to contribute a note or feedback.