and add this to functions.php if you want to search only in posts and pages.
function mk_searchfilter($query) {
if ($query->is_search && !is_admin() ) {
$query->set('post_type',array('post','page'));
}
return $query;
}
add_filter('pre_get_posts','mk_searchfilter');
Related Posts:
- Solr vs. ElasticSearch
- Search is always exact [closed]
- Empty search returns home page, how to return not found search page?
- Limit search to latin characters
- How to look at code in WordPress repositories without downloading?
- Display search results within the same page
- Insert DIV container below 1st search result
- How to make WordPress search prioritise page titles?
- How to add the author search in the default wordpress search?
- How do I redirect /search/ to wordpress search template?
- How to search for users based on added user metadata
- Search by Post ID and display content of the post in search result
- Let user change posts per page
- Turning Broken URLs Into Search Terms?
- Change the Search Base in a multi language wordpress
- Search uses index.php instead of search.php on renaming search field from “s”
- Changing the default WordPress search action
- Get the selected term in a dropdown search
- Separating search results collectively by type
- Set default text for the_search_query();
- Noindex, nofollow stuck on homepage
- What are the different options for excluding certain post types from search results?
- Is_search not working on search results page
- Search in post title and custom fields
- How to change users smart quotes to dumb quotes in search bar?
- Strange Search Queries in Apache Status
- Trim the search result around the search word
- Need to do blank search.
- Searching custom fields is removing search on the post_title column
- Edit search results in order to advertise
- 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.)?
- documentation for wordpress 3.7 keyword
- Using parent slug variable to display proper submenu not working properly
- WordPress Search not picking up text provided by a Plugin
- What does wordpress search, search?
- How to combine two get_users() array?
- why pre_get_posts works fine in post type archive, but not in search result list?
- How to get started?
- Search.php display results differently based on post type
- Search not working. Appending a “
- Search posts by Tag
- How to query two meta fields and display results between them
- Change Twentyeleven Search Form Text
- redirected to the login screen when I do a blank search
- Add Google custom search to wordpress.com [closed]
- Changing default wp search string
- How do I exclude a specific page (and child pages) from the search results?
- Sort WP Search results by date
- how to search everything
- changing search result from only excerpt to full content
- How to pass data to wordpress page (without GET parameter)
- Cannot pass ‘S’ parameter more than two letters
- Check If search query contains something?
- Show search count by post type
- How to search for post content and attached file names
- Alter BuddyPress member search to include search on added profile fields [closed]
- Enhancin 404 to contain a search from URL
- Checkboxed term search
- Searching for one letter returns extra empty post
- Search using ACF repeater
- search custom table in wp database with searchform
- How to track searches using the REST API?
- content-search.php duplicating the output for a certain post type
- Form for search pages by meta datas
- WordPress REST API Search decoded URL with cyrillyc symbols
- WordPress Search by tags
- Hide Search Form above results
- searchform.php not included by get_search_form when using wp_dropdown_categories
- Modify wordpress search to search only pages and load matched page not search results
- How to pass variable to get_search_form()?
- Problem with search results page
- Why the search results are wrong in search posts form?
- Search result page as a new page
- Search Engine Visibility Issue in WordPress
- Page has no template
- Search only blog posts on blog page
- Allow users to search for other users in WordPress
- 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
- How to stop the search results from loading the wrong template?
- search form display no result
- WordPress search not able to find text in url
- Search & Replace trailing strings
- Returning the entire line of a custom search result filter
- Page/Post path in Search Results
- Google Search and Own Website Search?
- How we filter the search base on post-meta tags
- Form Data Causes “Page Not Found”
- Search options/filters
- How to search for articles containing two words?
- Wp eCommerce meta information search [closed]
- Search results truncated
- “feed” added at the end of my URLs
- Disable – Post search field – for non-admin roles in WP dashboard
- Search results heading and counter not working – Oxygen Builder
- How to quickly search posts by title in Admin interface
- Blocking spambots from Search form