I would recommend you to use a hook for pre_get_posts
action. This action is fired before appropriate posts are fetched from db. In this hook you can add extra parameters to your query and have influence on returned results. So the basic implementation of your hook could be like this:
add_action( 'pre_get_posts', 'wpse8170_pre_get_posts' );
function wpse8170_pre_get_posts( $query ) {
if ( is_search() ) { // check if it is search page
$query->set( 'arg', 'value' ); // add additional arguments to the query
}
}
Pay attention that arg
and value
parameters are generic and was mentioned as example. You have to use correct arg
and value
for your query. All list of available arguments for the query you can read in codex.
Related Posts:
- Using pre_get_posts to rewrite search query to display posts from multiple taxonomies
- Exclude Specific Term from Search
- WordPress database error: [Not unique table/alias: ‘wp_postmeta’]
- WordPress Search – display taxonomy terms in results
- How to find taxonomy name using only taxonomy TERM ID (or taxonomy term name)
- Sort posts by number of matched terms
- How to add custom taxonomy to search
- Taxonomy.php issue with search and filters
- Extending wordpress search to include excerpts and taxonomies?
- How to filter WordPress search, excluding post in some custom taxonomies?
- how to search in custom fields & custom taxonomy for custom search
- Search by type posts and taxonomy
- Creating a custom search form
- How to implement custom search with input fields?
- How do I keep the page I’m on within the URL when running a search on a taxonomy?
- Add multiple taxonomy filters to edit.php that support search
- Extend & Search Native WordPress Image Galleries With Tags and Taxonomies?
- Custom Taxonomy Not Working When added to WordPress Search
- Search Tool only refreshes Page without showing results
- WordPress thinks my custom taxonomy pages are search pages #seo
- Removing “s” from search with custom parameters
- Passing form inputs into multi-taxonomy query
- Custom URLs in Custom Search Results
- Search Query for Multiple Terms In Same Taxonomy
- Use an HTML Element To Filter Taxonomies In WP Search
- Why isn’t the ‘no results’ being shown when a query returns no results?
- Clean Custom URL for Serach + Custom Taxonomy
- Advanced search redirecting to another page then filter further
- Search only custom taxonomies
- WordPress autocomplete search with taxonomies
- Geographic search with taxonomy structure [duplicate]
- Taxonomy or Custom Field
- Multiple Drop-Down custom taxonomies search
- Filter with two id of the same value CPT UI(taxanomies)
- Amend taxonomy to search in wordpress admin
- Include get_term_link inside search
- Product custom taxonomy is not found when space in name
- Rewrite Search URL Permalink For CPT Custom Taxonomies
- Search custom taxonomy via query-string?
- How to exclude woocommerece product category in search results?
- WordPress custom taxonomies new/edit post autocomplete
- Post not showing in my custom advanced search
- Include attachments with a custom taxonomy in search
- Custom taxonomy displayed in search results
- How to perform a search inside a specific taxonomy category
- Custom Taxonomy, shows empty value (home page of website)
- Advanced WordPress search form based on custom taxonomy and custom meta value
- Custom Search only for my Custom Taxonomy Page – data
- Search and filter with custom field in taxonomy
- Advanced search form with filters for custom taxonomies and custom fields
- wp_insert_term is adding a term that has no name
- Get total number of comments from posts in a specific custom taxonomy
- Display one post from each term in a custom taxonomy [closed]
- WordPress json api taxonomy index method
- get_terms showing link to category even if all posts are drafts
- How to restrict on selecting child taxonomy
- Is it possible to sort the post based on a custom field?
- How do I get terms as a list for a specific post?
- Change in custom taxonomy permalink causes 404 error for another custom taxonomy
- Displaying ACF image field [closed]
- How get custom field from custom taxonomy?
- Move terms from one taxonomy to another keeping the hierarchy
- Custom Taxonomy Tag Search
- Catchable fatal error on custom category post
- Custom Taxonomies not retaining hierarchy while importing from one site to another
- Output single post custom taxonomy child terms
- How to check if a post has at least 2 terms from a custom taxonomy attached?
- Custom Taxonomy template not display
- Terms Per Page in custom taxonomy Admin
- pre_get_posts post_meta event
- How can I add a custom permalink to a term?
- Custom taxonomy display name issue
- Variable Not Working Inside is_author() Array
- How do I hide a term from non-admin users in get_the_term_list?
- Need equivalent of single_term_slug
- List one post only from each subcategory using get_posts?
- Issue adding custom taxonomies to custom post type (PHP)
- How to loop custom posts that have an exact match in taxonomy terms?
- True or F False Setting of ‘with_front’ Parameter of Rewrite Is returning Exact Same result
- WordPress not saving tags for custom taxonomy term description
- How to Implement Custom Taxonomy Conditional Page?
- wp_insert_post not adding taxonomy (using wp_set_object_terms)
- Filter “get_terms” query
- Display multiple taxonomies in a function
- Remove Custom metabox from particular page template is used
- generate random slug when adding taxonomy
- Add and Custom category for posts “PAGE”
- Error 404 in Custom taxonomy with pagination
- Custom post type term names with ampersand in the term name
- WordPress Taxonomy Permalinks – Custom?
- Need help understanding a rewrite with multi-level taxonomy
- Display custom post term or taxonomy
- Attaching meta box to specific category/taxonomy in custom post type
- Change Permalink to Value of Custom Field
- Display custom post taxonomies
- Custom Taxonomy type in nav menu
- Advanced search: roles and multiple taxonomies
- Custom Fields link to other pages, not search
- Removing fields from category/taxonomy edit form
- Gravity Forms with Advanced Post Creation Add-On not updating ACF fields on custom taxonomy