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
- Exclude in search post and include only 3 pages
- Include bbPress topics and replies in WordPress search results?
- Missing feature image link function
- What’s the difference between home_url() and site_url()
- Remove “Category:”, “Tag:”, “Author:” from the_archive_title
- get_template_directory_uri pointing to parent theme not child theme
- How to customize the_archive_title()?
- remove empty paragraphs from the_content?
- What is the “with_front” rewrite key?
- Why use if function_exists?
- How to override parent functions in child themes?
- wp_enqueue_script was called incorrectly
- Add multiple custom fields to the general settings page
- Ajax call always returns 0
- 400 bad request on admin-ajax.php only using wp_enqueue_scripts action hook
- How long does a deprecated function live in core?
- Solution to render Shortcodes in Admin Editor
- How to add a data attribute to a WordPress menu item
- What’s the difference between esc_html, esc_attr, esc_html_e, and so on?
- remove_action on after_setup_theme not working from child theme
- plugins_url vs plugin_dir_url
- Remove type attribute from script and style tags added by WordPress
- How to run a function every 5 minutes?
- Best way of passing PHP variable between partials?
- Upload Multiple Files With media_handle_upload
- How to display custom field in woocommerce orders in admin panel?
- Adding fields to the “Add New User” screen in the dashboard
- Issues with title-tag and document_title_parts
- How do I get the current edit page ID in the admin?
- How to check if a user exists by a given id
- Why isn’t is_page working when I put it in the functions.php file?
- Add tags to the section via functions.php
- Add image size if page template
- How to create a custom order status in woocommerce!
- Remove Actions/Filters added via Anonymous Functions
- Adding a second email address to a completed order in WooCommerce [closed]