On this page
is_search(): bool
Determines whether the query is for a search.
Description
For more information on this and similar theme functions, check out the Conditional Tags article in the Theme Developer Handbook.
Return
bool Whether the query is for a search.
Source
File: wp-includes/query.php. View all references
function is_search() {
global $wp_query;
if ( ! isset( $wp_query ) ) {
_doing_it_wrong( __FUNCTION__, __( 'Conditional query tags do not work before the query is run. Before then, they always return false.' ), '3.1.0' );
return false;
}
return $wp_query->is_search();
}
Related
Uses
| Uses | Description |
|---|---|
| WP_Query::is_search() wp-includes/class-wp-query.php | Is the query for a search? |
| __() wp-includes/l10n.php | Retrieves the translation of $text. |
| _doing_it_wrong() wp-includes/functions.php | Marks something as being incorrectly called. |
Used By
| Used By | Description |
|---|---|
| wp_robots_noindex_search() wp-includes/robots-template.php | Adds |
| wp_get_document_title() wp-includes/general-template.php | Returns document title for the current page. |
| feed_links_extra() wp-includes/general-template.php | Displays the links to the extra feeds such as category feeds. |
| wp_title() wp-includes/general-template.php | Displays or retrieves page title for all areas of blog. |
| WP::handle_404() wp-includes/class-wp.php | Set the Headers for 404, if nothing is found for requested URL. |
| get_body_class() wp-includes/post-template.php | Retrieves an array of the class names for the body element. |
| redirect_canonical() wp-includes/canonical.php | Redirects incoming links to the proper URL based on the site url. |
Changelog
| Version | Description |
|---|---|
| 1.5.0 | Introduced. |
© 2003–2022 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/functions/is_search