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
- wp_mail not running inside Cron
- Remove product description from product archive page
- Increment price for Woocommerce Minicart [closed]
- Change woocommerce products weight varation based its product category or tags? [closed]
- Completely disable RSS feeds on WP 5.5.2 and show a 404 page instead of die();
- Check if row exists before inserting
- Missing argument 2 for a custom function widgets_init
- Removing the main link to Jetpack from the menu
- Defining a global array in functions.php?
- Set quantity of woocommerce product on page visit [closed]
- get_post_type() in in_array doesn’t work for some reason
- How to remove set_post_thumbnail_size() in child themes?
- How to load jQuery in the footer – nothing works for me
- how to en-queue jQuery to load before the tag
- How to add custom JavaScript in functions?
- srcset and custom field get_post_meta and wp_get_attachment_url
- hide shortcode using hooks
- Adding code using functions.php in child theme
- Extending a custom framework built into WordPress to automatically turn the ‘Search Engine Visibility’ setting ON / OFF, dependant on environment
- Page get parameter doesn’t work with is_single() function
- How can I change the size of the text in Word Press
- shorthand syntax for custom fields
- Show admin page, only if function is being used
- Get users with different roles and call function on each of them (user_meta)
- Show errormessages on wrong username/password on custom loginform?
- Class parameter in get_avatar args doesn’t get added to output
- Extend WordPress Audio Widget to accept HLS (.m3u8) URLs
- locking content with overlay/pop up ads
- show only one category and filter by tag
- 404 error when i try to search by category or by tag
- Mail function not working with user accounts
- Cant use php fopen() function in functions.php
- Adding function to function.php error 505 [closed]
- Can’t find function which is called in a wordpress theme
- Update post meta with wp cron
- How to delete rows from custom table within a time interval?