Setting the post type at pre_get_posts
can solve this. You can set it like below-
function the_dramatist_search_only_page($query) {
if ($query->is_search && !is_admin() ) {
$query->set('post_type',array('page'));
}
return $query;
}
add_filter('pre_get_posts','the_dramatist_search_only_page');
Hope it helps.
Related Posts:
- How to create live autofill search?
- How to search for (partial match) display names of WordPress users?
- How can i move search results onto a specific page?
- Unified search across separate WordPress installations
- How to insert a span inside a search form?
- Extending search query with additional $sentence value
- Search only blog posts (default WP search widget)
- Exclude pages from WordPress search result page
- Disable Redirect to Product Page on Search Results Page in WooCommerce [closed]
- Get user role by using user_id in buddypress
- Combining Meta_Query key values for one array
- Search: Only One Result Returned
- How to redirect search result page to post
- Create multiple Search functions for posts / custom post types and everything
- Custom Permalinks Break Search Pagination
- Include Author profile in search results
- Adding arg to search results page
- search only pages if on page
- I’m trying to expand the scope of the default WP search algorithm. What am I doing wrong?
- Replace default WordPress search behavior with Sphinx
- How to return HTTP 404 when no search results found?
- Change query variable for wordpress search
- Search Results: Differentiate posts and pages
- How to disable WordPress Search from Url?
- How does WordPress know if a URL doesn’t exist?
- Highlight Search Results in Function.php
- Changing search slug from + to – (hyphen)
- How to make a search form?
- Force is_search to always TRUE
- Add search box to page
- Using ElasticSearch on WordPress
- How to restrict wordpress search to pages and disable products listing search?
- WordPress does not find author pages in search
- remove post edit.php search form and replace with my own
- Get most searched keywords in WordPress
- Search bar in table in wordpress
- Where does the Yoast SEO plugin set the Open Graph metadata?
- search filter add priority to post_type and add order to some post_type
- How do I add custom fields data to a search index?
- Empty search results return soft 404
- meta_query issue with multiple numerics
- How do I search events between two set dates inside WP?
- searchform.php :: pass second query string variable with same value as ?s=
- Limit search to custom field
- How can I get a traceback on function calls?
- How to have search results page sorted by post date
- Search Results Page outputs HTML code
- Custom Query Content Filtering
- Search buddypress groups with querystring in url
- Make search result display 1 Company or 2 Companies
- Displaying number of search results for each post type
- Search returns everything if search term has a space
- Change Twentyeleven Search Form Text
- redirected to the login screen when I do a blank search
- BuddyPress – Search members by name and also by username
- Include results with tags relevant to the search keyword with JSON rest API v2
- Search function does not work on mobile devices
- Changing the ORDER BY in WordPress default search function
- How do I exclude a specific page (and child pages) from the search results?
- How to pass data to wordpress page (without GET parameter)
- How Can I Make Dynamic Search Form While Converting Html To WordPress?
- Get the search element only on 404
- Specific website content
- Second page (and next) of search results redirects me to the home page
- Alter BuddyPress member search to include search on added profile fields [closed]
- search results to a variable in search.php
- Load search results into a div
- Search in posts’ attachments: title, caption, description
- Exclude certain Gutenberg blocks from search results
- How to order search results so a specific page appears first when user searches for a particular word?
- content-search.php duplicating the output for a certain post type
- make link to search page
- Search results thumbnails different size
- Hide Search Form above results
- WordPress User Search Based on Latitude and Longitude
- Remove gray header on Search Result page on WordPress
- How do i get The dropdown to have the value of the sub cat and custom fields
- Why are archived pages showing up in searches and able to be accessed?
- Enable query based wordpress search ?s=
- Partial searches for wp_usermeta
- Search result page as a new page
- Search terms in other language turns out to question mark and symbols
- Adding thumbnail to search results & changing content.php
- Create a custom and powerful search form
- How to search for categories instead of products in Woocommerce?
- Search results show only content by admin post authors
- Buddypress Activity search with OR query instead of AND
- How to exclude one post format from search result?
- Help with WordPress search
- Custom Search Form WP_Meta_Query – Filtering Custom Fields
- Search not displaying results
- Relevanssi show only 1 result
- I need a custom search page to lead to search.php but it goes to index.php
- How To Change Url Doing Some Changes in Search Form
- Adding search box for admin on custom admin page
- Different search results with WordPress and Relevanssi
- How do I find a shortcode stored in wordpress?
- WordPress Search – Reject partial matches
- Wp query search built out of 4 terms?
- Ivory Search error