asp_query_args
// Classic Usage
add_filter("asp_query_args", "asp_query_args_change", 10, 2);
function asp_query_args_change($args, $search_id) {
// Do your stuff with the $args array
// ....
// Then return
return $args;
}
// Shorter version with type safety and anonymous function
use WPDRMS\ASP\Models\SearchQueryArgs;
add_filter("asp_query_args", function(SearchQueryArgs $args, int $search_id) {
return $args;
}, 10, 2);Parameters
Example: Explicitly changing the post types and post fields to search
Accepted Properties of the $args object
Generic arguments
's' - Search phrase
'search_type' - Search content types
'engine' - Search engine type
'keyword_logic' - Keyword logic
Global results limit
Results limit by results type
Post & custom post type search related arguments
'post_type' - Post type
'post_status' - Post statuses
'post_fields' - Post fields to search in
'post_custom_fields' - Post custom fields to search
'post_in' - Posts by IDs
'post_not_in' - Posts exclusion by IDs
Primary and secondary ordering
'post_tax_filter' - Filter posts by taxonomy terms
'post_meta_filter' - Filter posts by post meta (custom fields)
'post_date_filter' - Filter posts by dates
'post_user_filter' - Filter by author (user)
Attachment search related arguments
BuddyPress search related arguments
Taxonomy Term (category) search arguments
User search related arguments
Special arguments
Allowing missing translations in results when using WPML
Last updated