wp_query_search_exclusion_prefix
Filter HookDescription
Filters the prefix that indicates that a search term should be excluded from results.Hook Information
File Location |
wp-includes/class-wp-query.php
View on GitHub
|
Hook Type | Filter |
Line Number | 1489 |
Hook Parameters
Type | Name | Description |
---|---|---|
string
|
$exclusion_prefix
|
The prefix. Default '-'. Returning an empty value disables exclusions. |
Usage Examples
Basic Usage
<?php
// Hook into wp_query_search_exclusion_prefix
add_filter('wp_query_search_exclusion_prefix', 'my_custom_filter', 10, 1);
function my_custom_filter($exclusion_prefix) {
// Your custom filtering logic here
return $exclusion_prefix;
}
Source Code Context
wp-includes/class-wp-query.php:1489
- How this hook is used in WordPress core
<?php
1484 * @since 4.7.0
1485 *
1486 * @param string $exclusion_prefix The prefix. Default '-'. Returning
1487 * an empty value disables exclusions.
1488 */
1489 $exclusion_prefix = apply_filters( 'wp_query_search_exclusion_prefix', '-' );
1490
1491 foreach ( $q['search_terms'] as $term ) {
1492 // If there is an $exclusion_prefix, terms prefixed with it should be excluded.
1493 $exclude = $exclusion_prefix && str_starts_with( $term, $exclusion_prefix );
1494 if ( $exclude ) {
PHP Documentation
<?php
/**
* Filters the prefix that indicates that a search term should be excluded from results.
*
* @since 4.7.0
*
* @param string $exclusion_prefix The prefix. Default '-'. Returning
* an empty value disables exclusions.
*/
Quick Info
- Hook Type: Filter
- Parameters: 1
- File: wp-includes/class-wp-query.php
Related Hooks
Related hooks will be displayed here in future updates.