post_search_columns filter-hookWP 6.2.0

Filters the columns to search in a WP_Query search.

The supported columns are post_title, post_excerpt and post_content. They are all included by default.


add_filter( 'post_search_columns', 'wp_kama_post_search_columns_filter', 10, 3 );

 * Function for `post_search_columns` filter-hook.
 * @param string[] $search_columns Array of column names to be searched.
 * @param string   $search         Text being searched.
 * @param WP_Query $query          The current WP_Query instance.
 * @return string[]
function wp_kama_post_search_columns_filter( $search_columns, $search, $query ){

	// filter...
	return $search_columns;
Array of column names to be searched.
Text being searched.
The current WP_Query instance.


Since 6.2.0 Introduced.

Where the hook is called

wp-includes/class-wp-query.php 1444
$search_columns = (array) apply_filters( 'post_search_columns', $search_columns, $q['s'], $this );

Where the hook is used in WordPress

Usage not found.