You dan do this in the pre_get_posts hook. You can find a few examples on that page too 🙂
Related Posts:
- How to redirect to post if search results only returns one post
- Possible to search by author name with default WordPress search function?
- paginate_links() don’t properly work in search.php?
- Filter the query ONLY for the search results page
- Extending the site search to include a single custom field
- Modify search function in WordPress (TwentyTwelve)
- How to customize search result page title?
- Remove tag on my RSS Feed
- Display WordPress Search
- get_the_excerpt() not returning anything when post has no excerpt
- Automatically add author’s name to post_tag
- Adding a class to tag list in a function
- Search user metadata with checkboxes via ajax (almost working)
- Searching for content post
- Create single.php for specific tag by tag id or name
- list tags with count in author profile page
- Product Tags in Add New product as checkbox list [closed]
- Retrieve tags data in post body
- Echo tags used to describe the theme
- changing behaviour of get_search_form
- Frontend tag edit/submit form
- Is possible add icon in title posts only in specific tag?
- Search filter by Post title OR Meta Title Value [duplicate]
- Using wp_redirect and .htaccess to re-route searches (and pass along the remaining GET vars)
- paginate_links() don’t properly work in search.php?
- Display tags that only appear in one category
- Add a unique class to HTML tag/element
- How to edit the Tags within the image file URLs?
- Function filter breaking tag archive menus
- Tags break custom Excerpt function
- Numbering lines of code with the tag?
- Include the post type before the title of search results
- Randomizing wp_tag_cloud() in child theme
- How to rewrite wordpress search to work on specific category
- two search forms on the same page
- Sort and display pages with specific custom field (not tag)
- search form leads to 404
- Function to echo (or display?) wordpress tags in the head section
- Custom function for search form
- WordPress: Highlight search result exact matches
- What is wp_get_post_tags for media tags?
- Allow user only create specific tags
- Limiting WordPress Search function : Custom build
- Removing sanitize_title_with_dashes Function with The Real Title
- More than one search results page template for two searches on site
- How do i create a search option for pdf’s only
- method to fetch entire tag list on archive.php
- Form output outside of container
- require_once() Causing categories and tag pages on dashboard to not refrsh
- Change post count on tag/terms pages to 10
- Limit Number of Posts on Blog Category Page Throwing 404 Error on Paginated Pages
- Custom taxonomy not refreshing page on add
- us states dropdown function and echo in theme template files
- Automatically add tag if a checkbox is checked
- getExcerpt: Make ellipsis appear only if character limit is reached
- Pagination in Search result
- How to get tags and categories?
- child_of not working while searching
- Search Woocommerce product titles only
- If two tags in the middle i need comma
- Display function from functions.php in tag.php
- Custom Post Type Search
- Bulk set Post Title as Tag where Tag is Empty Function
- The search doesn’t work properly
- Check if the user has explicitly set an excerpt
- Add inline css to theme
- Shortcode with custom content attribute?
- Add a Post Thumbnail to an RSS Feed with custom size
- Print Dashboard menu name and link
- Develop function get_template_part in functions.php
- Change comment_reply_link URL
- Ajaxing function in widget class
- Select pages by category
- wp_register_script(… $in_footer = true) not working
- Output and filter data from a XML url
- How do I create a function that simulate the click on Update button for all posts?
- Multisite Ajax serialize return error [object Object]
- Wp admin – Set default value to 999 in comments
- wordpress use single ajax in place of multiple ajax requests in a smarter way
- Can’t properly set the_title add_filter to show short_URL
- WordPress function, Run using Crontab
- Can set_post_thumbnail be used to remove a thumbnail?
- resizing of thumbnails not working
- Changing date query from month
- the_date() and the_time() functions display actual date an time instead of published date and time
- Can’t load assets
- Delete oldest wordpress post (SQL query)
- Warning and fatal error
- Featured image on archive page based on post type
- Adding an IF ELSE to a function
- wordpress ajax is not working for dropdown selection
- is_page_template wont allow me to enqueue scripts
- Updating site content after an AJAX call without a page reload
- jQuery HoverIntent is not a function
- Changing functions.php and .htaccess files
- Code in functions.php appearing on front-end and dashboard [closed]
- Sessions in word press [duplicate]
- “woocommerce_output_related_products” not working
- How to overwrite image if it already exists – WordPress, Gravity form
- Change TinyMCE undeline outpout