Filter hook 'get_search_query'

in WP Core File wp-includes/general-template.php at line 4464

View Source

get_search_query

Filter Hook
Description
Filters the contents of the search query variable.

Hook Information

File Location wp-includes/general-template.php View on GitHub
Hook Type Filter
Line Number 4464

Hook Parameters

Type Name Description
mixed $search Contents of the search query variable.

Usage Examples

Basic Usage
<?php
// Hook into get_search_query
add_filter('get_search_query', 'my_custom_filter', 10, 1);

function my_custom_filter($search) {
    // Your custom filtering logic here
    return $search;
}

Source Code Context

wp-includes/general-template.php:4464 - How this hook is used in WordPress core
<?php
4459  	 *
4460  	 * @since 2.3.0
4461  	 *
4462  	 * @param mixed $search Contents of the search query variable.
4463  	 */
4464  	$query = apply_filters( 'get_search_query', get_query_var( 's' ) );
4465  
4466  	if ( $escaped ) {
4467  		$query = esc_attr( $query );
4468  	}
4469  	return $query;

PHP Documentation

<?php
/**
	 * Filters the contents of the search query variable.
	 *
	 * @since 2.3.0
	 *
	 * @param mixed $search Contents of the search query variable.
	 */
Quick Info
  • Hook Type: Filter
  • Parameters: 1
  • File: wp-includes/general-template.php
Related Hooks

Related hooks will be displayed here in future updates.