Available since: 1.1
searchwp_query_conditions
View Parameters »The SearchWP search algorithm is based on a unique SQL query that retrieves results from the SearchWP database tables. You can modify the conditions used in the algorithm using this hook.
Example: To directly manipulate the SQL used for each post type in the main search algorithm, add the following to your active theme’s functions.php
:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function my_searchwp_query_conditions( $sql, $postType, $engine ) { | |
// modify $sql to your liking | |
return $sql; | |
} | |
add_filter( 'searchwp_query_conditions', 'my_searchwp_query_conditions', 10, 3 ); |
Parameters
Parameter | Type | Description |
---|---|---|
$sql |
String |
The original SQL |
$postType |
String |
Current post type (all enabled post types are iterated) |
$engine |
String |
The search engine being used |