asp_query_{type}
Gives access to the query string, before executing.
Gives access to the specific type of search query string, before executing.

Types

  • asp_query_cpt
  • asp_query_indextable
  • asp_query_attachments
  • asp_query_terms
  • asp_query_users
  • asp_query_comments
1
// Regular engine post type search query
2
apply_filters('asp_query_cpt', string $query, array $args, int $search_id, bool $is_ajax);
3
// Index table post type engine search query
4
apply_filters('asp_query_indextable', string $query, array $args, int $search_id, bool $is_ajax);
5
// Attachment search query
6
apply_filters('asp_query_attachments', string $query, array $args, int $search_id, bool $is_ajax);
7
// Taxonomy term search query
8
apply_filters('asp_query_terms', string $query, array $args, int $search_id, bool $is_ajax);
9
// User search query
10
apply_filters('asp_query_users', string $query, array $args, int $search_id, bool $is_ajax);
11
// Comments search query
12
apply_filters('asp_query_comments', string $query, array $args, int $search_id, bool $is_ajax);
Copied!

Parameters

  • $query (string) - SQL query string
  • $args (array) - Search arguments
  • $search_id (int) - Search instance ID
  • $is_ajax (bool) - Is the current request an ajax search
Always be careful when making direct changes to a query, as it is directly sent to the database server for execution.

Usage

1
add_filter( 'asp_query_cpt', 'asp_modify_query_string', 10, 4 );
2
function asp_modify_query_string( $query, $args, $search_id, $is_ajax ) {
3
$query = str_replace('wp_postmeta', 'wp_my_postmeta', $query);
4
return $query;
5
}
Copied!
Last modified 1yr ago
Copy link