posts_search WordPress Filter Hook

The posts_search hook is a great way to add custom search functionality to your Wordpress site. This hook allows you to modify the SQL query that is used to search for posts, giving you full control over the search results. This hook is perfect for adding custom search features to your site, or for tweaking the default search behavior to better suit your needs.

apply_filters_ref_array( 'posts_search', string $search, WP_Query $query ) #

Filters the search SQL that is used in the WHERE clause of WP_Query.


Parameters

$search

(string)Search SQL for WHERE clause.

$query

(WP_Query)The current WP_Query object.


Top ↑

More Information

Since version 3.0.0, the posts_search filter is used to filter the search SQL that is used in the WHERE clause of WP_Query.


Top ↑

Source

File: wp-includes/class-wp-query.php

View on Trac



Top ↑

Changelog

Changelog
VersionDescription
3.0.0Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.

Show More