Copy below code and paste in function.php file to exclude pages from search results.
if (!is_admin()) {
function wpb_search_filter($query) {
if ($query->is_search) {
$query->set('post_type', 'post');
}
return $query;
}
add_filter('pre_get_posts','wpb_search_filter');
}
Related Posts:
- How to make search engine index PDF files? [closed]
- How to override normal WordPress search in Buddypress? [closed]
- Search and replace text across all posts
- How would implement StackExchange ‘Questions with similar titles’ for the FAQ on my wordpress site
- dynamic page not indexed
- How to get posts by content?
- WP-PageNavi plugin doesn’t work with multiple pages of search results
- Problem with Search Results in WP (not displaying the full posts)
- How to improve WordPress search
- Creating search filter through plugin
- How do I add advanced custom fields / meta fields to Elasticsearch? [closed]
- plugin to search entire posts, blogs, forum, users [closed]
- Automatically adding category filter based on search string
- How can I reuse the WordPress search form for a custom plugin / widget?
- Custom Taxonomy Tag Search
- What causes an Unexpected HTTP Error within install plugins?
- What is the best way to mimic a search query within a plugin
- Is there a way I can find wordpress posts that don’t contain a word?
- Search is not working on plugin directory
- Search Everything plugin integration
- AJAX search posts and pages
- Search for categories
- AJAX search as you type? [duplicate]
- WooCommerce search products between price range using WP_Query
- Send admin an email when a user’s search has no results
- Integrate Algolia to WordPress site
- How to multiply a post to test internal search results?
- How to set “split_on_numerics” to false in ElasticSearch mapping using ElasticPress? (for proper SKU search in WooCommerce) [closed]
- Woocommerce Backend Search by Title and SKU
- Search and Filter Plugin – How to disable redirection
- WordPress Multi-Step Product Search
- Search by Attachment ID
- Custom search search does not work?
- Creating a search form and displaying results
- Is it save to replace with in WordPress search form
- WordPress search shows protected content
- Best approach to make all tags searchable by the wordpress search function
- How to search post titles with whole words only, but not the exact word only?
- RSS feeds for specific topics
- How to add the search page link to the anchor tag?
- WC Fix Attributes – ‘Add New’ Not Searchable/Delayed
- How to hide an option from dropdown in filter module
- WP search box on page not finding .PDF files
- Redirect to a page while maintaining search query parameters without causing an infinite loop
- Search results to point to specific section?
- Search in WordPress
- Content disappears when searching with Search & Filter plugin
- Accounting for search terms that may include a space, using SearchWP
- how to add navigation icons in specific template?
- multiple string replace of post’s content for large data
- How can I make the search bar in my wordpress site search all of the pages rather than just the blog posts?
- How to make wp multisite subdomain exist search
- Remove Url Parameter WordPress
- How can I remove this sidebar from my Search Results page?
- History of page, interval of years
- Include post_date in search
- How to order users alphabetically by name? in plugin UPME
- How to hook into search results template or query?
- Add “selected” class to custom taxonomy dropdown search
- WordPress Search return wrong results
- Differentiate attachment pages in search results
- Is there any simple wordpress search template that works with existing searchforms?
- Extend WordPress Search
- how to sort results by last day update at search result in plugin installer?
- Jigoshop search taxonomy
- Strange Search Query Appearing on Google Index – “/?q=Save+Us+From+Berlusconi”
- Dave’s WordPress Live Search only works when logged in as admin
- wordpress Search function is not working
- Multi-step, live updating search
- Can we install 3d product configurator into wordpress
- LiteSpeed cache image Optimization
- How to set an exact search box in tablepress plug-in
- How can I use WordPress functions in my stylesheet?
- Where the Nickname is being used in WordPress
- Should a SEO plugin be necessary? [closed]
- woocommerce product attributes
- How can I rewrite a plugin generated URL?
- WordPress language switcher
- Restore a Plugin’s Default Settings
- Mass Import Users without sending new user notification
- WordPress login with Phone Number [closed]
- How to correctly detect accessing wp-content/uploads?
- Disable multisite-wide plugins on specific sites
- WordPress plugin – Error “Plugin generate 2890 characters of unexpected output when activated”
- Adding a slider captcha to the comment system
- Rotating background images with admin options
- Display Swift Snippets in WordPress
- Add custom JavaScript that is a combination of CDN/uploaded files and easily-edited code?
- Wysiwyg editor errors
- Conditional tag in Widget Logic for checking if top level page or if subpage
- Creating Featured Content Boxes
- REST API can’t get the response manually
- How to make a textarea accept javascript in my settings apge?
- Trying to use shortcode for a plugin on custom homepage of Responsive theme
- Add a WooCommerce Product Variant with attributes programmatically
- Get only selected custom taxonomy
- WordPress update plugin through Dashboard/Plugins displaying error
- Authenticating custom field on login
- How to get rid of error message of custom metabox in dashboard when moving out of edit page?
- Select posts from list and add them in a new list