Menu Adam R Brown

WP hooks navigation: Home/browseActions indexFilters index

Source View: wp_query_search_exclusion_prefix

To save our bandwidth, we show only a snippet of code around each occurence of the hook. View complete file in SVN (without highlighting).

Understanding Source Code

The best way to understand what a hook does is to look at where it occurs in the source code.

Remember, this hook may occur in more than one file. Moreover, the hook's context may change from version to version.

Source View

Line Code
1277
1278           /**
1279            * Filters the prefix that indicates that a search term should be excluded from results.
1280            *
1281            * @since 4.7.0
1282            *
1283            * @param string $exclusion_prefix The prefix. Default '-'. Returning
1284            *                                 an empty value disables exclusions.
1285            */
1286           $exclusion_prefix = apply_filters( 'wp_query_search_exclusion_prefix', '-' );
1287
1288           foreach ( $q['search_terms'] as $term ) {
1289                // If there is an $exclusion_prefix, terms prefixed with it should be excluded.
1290                $exclude = $exclusion_prefix && ( $exclusion_prefix === substr( $term, 0, 1 ) );
1291                if ( $exclude ) {
1292                     $like_op  = 'NOT LIKE';
1293                     $andor_op = 'AND';
1294                     $term     = substr( $term, 1 );
1295                } else {