you can change your search filter to this:
function SearchFilter($query) {
$post_type = $_GET['post_type'];
if (!$post_type) {
$post_type="any";
}
if ($query->is_search) {
$query->set('post_type', $post_type);
};
return $query;
}
add_filter('pre_get_posts','SearchFilter');
then on your news search form add :
<input type="hidden" name="post_type" value="post" />
on your custom post type listing search form add
<input type="hidden" name="post_type" value="customtypename" />
and on the entire site search for don’t add anything
an you are set.
Related Posts:
- How can I implement a location based (zip code) search in WordPress?
- pre_get_posts and search query for admin
- Search function works improperly
- Force is_search to always TRUE
- How to conditionally pass a parameter to wordpress search to limit post types?
- How to exclude pages from WP search based on page title
- why pre_get_posts works fine in post type archive, but not in search result list?
- Search for two strings in WP search
- Displaying number of search results for each post type
- Use pre_get_posts to display search results by meta in specific order
- Search custom posts by meta key in admin
- pre_get_posts improperly searching revisions
- WP search in metadata post
- meta field search too restrictive in pre_get_post() for custom search
- Help with WordPress search
- search filter for search and tag page doesn’t work
- Consistent and Admissible Heuristics
- How do you make Vim unhighlight what you searched for?
- How to create live autofill search?
- Empty search input returns all posts
- WP User Query with search columns and meta query
- Get user role by using user_id in buddypress
- Add custom field (value) to search result (without plugin)
- Search uses index.php instead of search.php on renaming search field from “s”
- Changing the default WordPress search action
- Set default text for the_search_query();
- What are the different options for excluding certain post types from search results?
- Search in post title and custom fields
- How to change users smart quotes to dumb quotes in search bar?
- Searching through different categories on different pages code is not working
- Trim the search result around the search word
- Searching custom fields is removing search on the post_title column
- Edit search results in order to advertise
- How to do multiple searches (with logical OR) in WP_Query in hook pre_get_posts?
- Multiple meta_values in the pre_get_posts filter?
- Custom post type search using $_SESSION and pre_get_posts
- WordPress, fetching users with an exact match in a string of comma separated values in user_meta
- search form redirects to home
- How can I hide uncategorized products from search results?
- Exclude html from search results (image names, etc.)?
- Removing “s” from search with custom parameters
- documentation for wordpress 3.7 keyword
- Get Adjacent post by search query
- How to get started?
- How to reset usual $query on search page to push custom $wpdb query there?
- Search.php display results differently based on post type
- Search – Only search for post meta field
- Improved WordPress search functionality and search form plugin
- Use wordpress search to display results within a post
- How to query two meta fields and display results between them
- Sorting search results with custom dropdown
- how to search everything
- changing search result from only excerpt to full content
- Cannot pass ‘S’ parameter more than two letters
- Localization of WP theme
- How to have multiple instances of the same taxonomy in a search form
- WP + Google analytics = /search?
- Search result count not matching actual result
- How to search for post content and attached file names
- Search engine for WP as CMS [closed]
- Searching for one letter returns extra empty post
- How to create a search form with multiple search fields
- Block internal search queries with pre_get_posts and regex rules
- Search Exact on WordPress – Relevannsi Solution Not Working
- REST API: Search products only in the names
- Bots using internal wordpress search
- WordPress search – Display the paragraph which has the searched word/term
- Altering search results to handle a post meta field not working in current WordPress
- WordPress Search by tags
- WordPress search post using unicode
- Create search box on Archive Custom post type
- How to pass variable to get_search_form()?
- Why the search results are wrong in search posts form?
- Search isn’t displaying all results
- How to use regular page template for search results?
- Search only blog posts on blog page
- Search: display all found matches inside post
- Auto search field without buttons, shows first result from search page
- Can I set up a search box that uses fields?
- How to Search Users on the Base of Latitude and Longitude in Users meta_key and meta_value
- Returning the entire line of a custom search result filter
- Run search query again without pagination gives no results?
- search does not yield access restricted results
- Customizing Home Page with Pagelines Platform
- Search Limited to Categories Not Working
- Google Search and Own Website Search?
- How we filter the search base on post-meta tags
- Make search result returned only from tags! [duplicate]
- Form Data Causes “Page Not Found”
- WordPress search form and input type=”image”
- Search options/filters
- How to search pdf attachment?
- Website Search Results Not Showing Images
- How to search for articles containing two words?
- Wp eCommerce meta information search [closed]
- Making ACF fields appear in search results
- How to make wordpress Dynamic Search-icon from Predesigned Static Html Search-icon?
- search ALSO by POST-ID with a public front-end search box
- how to create a multi selector dropdown search box by code?
- Display search results within the same page in wordpress