asp_query_args
The asp_query_args filter provides a possibility to add/remove/change query arguments right before they are passed to the ajax search pro main query.
This filter is executed after the search options were processed!
Parameters
$args (SearchQueryArgs) - the object of the arguments (structure detailed in chapter below). This object implements the ArrayAccess interface in a way that all of it's properties are accessible as array keys as well.
$search_id (int) - the current search ID
Example: Explicitly changing the post types and post fields to search
Accepted Properties of the $args object
For the complete $args source list with type hints and accepted values please check:
wp-content/plugins/ajax-search-pro/includes/classes/Models/SearchQueryArgs.php
The $args object is the heart and soul of this filter. By changing it's key values you can directly affect the search outcome.
The default values of the key arguments depend on the search intance configuration and the passed arguments from the front-end before the search process.
It is recommended to treat the $args variable as SearchQueryArgs object instad of an array to get type hints in your editor.
Generic arguments
's' - Search phrase
The search phrase.
'search_type' - Search content types
Determines the search content types. If you wish to return different content types as defined in the search instance option, then this needs to be properly stated within this option.
Type: array, Possible values:
cpt -> posts, pages, custom post types
taxonomies -> tags, categories and taxonomy terms based on taxonomy slug
users -> users
blogs -> multisite blog titles
buddypress -> buddypress groups or activities
comments -> comment results
attachments -> file attachments
'engine' - Search engine type
The search engine to use (regular or index). Change this to "index" only if the index table is configured!!
Type: string, Possible values: regular, index
'keyword_logic' - Keyword logic
The keyword connection logic which is used for the entered search phrases.
Type: string, Possible values:
OR (default) - matches if either of the phrases matches, even partially
AND - matches if both phrases match, even partially
OREX - matches if either of the phrases matches, only whole words
ANDEX - matches if both phrases match, only whole words
Global results limit
The maximum number of results set. If set to 0, then the result type limits are used instead.
If explicitly set to higher than 0, then the results count is distributed evenly for each source.
Results limit by results type
Only works if the 'limit' argument is set to 0. Defines limits for each source. The '_override' suffixed arguments are for the non-ajax search results.
Post & custom post type search related arguments
These arguments affect the post/cpt search.
'post_type' - Post type
Array of post types to search within.
Type: array, Possible values: post, page, ..any registered post type slug
'post_status' - Post statuses
Array of post statuses
Type: array, Possible values: publish, draft, private, trash, ..any registered custom status
'post_fields' - Post fields to search in
Array of search fields to search in
Type: array, Possible values: 'title', 'content', 'excerpt', 'terms'
'post_custom_fields' - Post custom fields to search
Array of custom field name
Type: array, Possible values: any custom field name
'post_in' - Posts by IDs
Limit potential results pool to array of IDs. This only affects the potential result pool, all the other defined criteria must also match!
Type: array, Possible values: existing post IDs
'post_not_in' - Posts exclusion by IDs
Explicity exclude IDs from search results
Type: array, Possible values: existing post IDs
Primary and secondary ordering
Type: string, Possible values: 'relevance DESC', 'post_date DESC', 'post_date ASC', 'post_title DESC', 'post_title ASC'
'post_tax_filter' - Filter posts by taxonomy terms
Array of taxonomy term rules.
Type: array, Possible values: array of rules
'post_meta_filter' - Filter posts by post meta (custom fields)
Array of custom field rules.
Type: array, Possible values: array of rules
'post_date_filter' - Filter posts by dates
Array of date rules.
Type: array, Possible values: array of rules
'post_user_filter' - Filter by author (user)
Array of user rules.
Type: array, Possible values: array of rules
Attachment search related arguments
Before adjusting the settings, enable attachment search explicitly:
Default attachment search arguments:
For the possible mime types, see the mime types table on the attachment search documentation page.
BuddyPress search related arguments
Before adjusting the settings, enable buddypress search explicitly:
Default arguments:
Taxonomy Term (category) search arguments
Before adjusting the settings, enable taxonomies search explicitly:
Default arguments:
User search related arguments
Before adjusting the settings, enable users search explicitly:
Default arguments:
Special arguments
Allowing missing translations in results when using WPML
If the site language is used, the translation can be non-existent if not marked with a language explicitly. This allows excluding those results if needed.
Last updated