apply_filters( 'post_search_columns', string[] $search_columns, string $search, WP_Query $query )
- Since
- 6.2.0
Filters the columns to search in a WP_Query search.
Description
The supported columns are post_title, post_excerpt and post_content.
They are all included by default.
Compatibility
- WordPress
- since 6.2.0
- 6.7.7
- 6.8.8
- 6.9.7
- 7.0.4
- 7.1.0
Present in every tracked release (6.7.7 to 7.1.0).
Parameters
$search_columnsstring[]- Array of column names to be searched.
$searchstring- Text being searched.
$queryWP_Query- The current WP_Query instance.
Where this hook fires · 1
wp-includes/class-wp-query.php:1483WP_Query::parse_search()
Source code
* @since 6.2.0 * * @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. */ $search_columns = (array) apply_filters( 'post_search_columns', $search_columns, $query_vars['s'], $this ); // Use only supported search columns. $search_columns = array_intersect( $search_columns, $default_search_columns ); if ( empty( $search_columns ) ) { $search_columns = $default_search_columns; }Changelog
Introduced in 6.2.0. Unchanged from 6.7.7 through 7.1.0.
Signature, return type and hooks compared across 5 parsed releases.
About this page
- Parsed data
- Generated from the wordpress-develop 7.1.0 tag, and regenerated for each WordPress release so it tracks the code rather than a snapshot of it.
- Corrections
- Something wrong on this page? Report it and it gets fixed in the next regeneration.