You can use pre_get_posts filter to filter out what you need. There’s an example on how to do this in Codex:
function search_filter($query) {
if ( !is_admin() && $query->is_main_query() ) {
if ($query->is_search) {
$query->set('post_type', 'post');
}
}
}
add_action('pre_get_posts','search_filter');
Also, this article might get you in the direction of editing the search form…
Related Posts:
- Make Google index the entire post if it is separated into several pages
- How to correctly submit a search form and display the result in an independent page
- Genesis – Customize search form
- How to exclude pages from the search results
- Show content if parent page has children
- Rewriting search and pagination base
- How to find objects by terms
- How to create a WP_Query to search the Title or Tag?
- How can i display 3 post types in same page?
- Adjust the results quantity for Search Results page pagination
- How to block specific keywords from searching on WordPress?
- How do I get images (with a thumbnail preview) to show in search results?
- Get only the grandchildren, not the direct children of page/current page?
- Enhanced WordPress Search
- Continue execution after WP REST API response
- Can I use HTTP POSTs? Is there a better alternative?
- Use wp_get_recent_posts with search term
- How to do multiple searches (with logical OR) in WP_Query in hook pre_get_posts?
- Change Navigation Bar based on logged in or not
- Only show search results with if current date is between two dates?
- How to make a search button that will search my website?
- How do I list the child of a child page [duplicate]
- How to hide all child pages with post_query?
- How to add seperate classes to no-search-result and found-search-result pages on wordrpess search – is_search()
- dividing sub-categories by parent category – WordPress
- Custom search results page not working with empty search
- WordPress default Search function inconsistent in WooCommerce Product Titles
- Save Search System
- Seach custom post type posts only by meta fields?
- Search not showing all results
- Autocomplete search box
- How do I Turn This Into An if statement?
- Search Query: how to construct a search string from two select elements?
- Query Pages and post excerpts dynamically
- Search WordPress using static html page
- Search form does not work in my website
- How to deal with too many $_POST variable conditions from ajax request at backend? [closed]
- Form search query – displaying ACF “Post Object” field as results
- WordPress child pages not working
- List post by title length
- Display child page content of a specific parent on home page
- How do I remove duplicate users from two merged WP_User_Query objects?
- How do I query a single data value from the wp_metadata table?
- Searching Posts Programmatically in a WordPress Plugin
- Search only working on front page (index) , not working on other pages
- Live search from database table
- WordPress Search
- WordPress pagination not working in search result page
- Search.php gets metadata from first post
- Validate search against a list of codes in wordpress
- search.php to search only the post title
- Display WordPress search results based on the selected Sub-Category
- Obfuscate links (for SEO purpose) [closed]
- WordPress Search Ajax + Isotope + InfiniteScroll
- how can i include post meta in search result
- Highlighting Text in Search Results
- Build A Custom SQL Query for WordPress Search
- Include custom fields in search
- Integrate admin plugin into template. Very interesant (live search + autocomplete with wp rest api, in vanilla js)
- Using a new WP_Query inside the loop
- How to search order using database frontend short code WordPress
- Limit Search to Product Pages only unless I’m on Blogpage or Blogposts
- Adding ELSE argument to AJAX Live Search for “No results found”
- How can i find wrong word in search box and replace with correct word
- Help me understand how Search function works using dynamic_sidebar()
- Should I use wp_cache in my plugin to make it faster?
- Searching a custom WP table and displaying results in an HTML table
- Child and Parent Pages list of sub pages
- My search results are only showing 5 posts?
- Include search tags and users in my search results system
- what’s the syntax for if the image exists get the image?
- making a search.php query
- Getting a value from a custom field from a page that shares a parent with the current page
- How can the searchform.php know if it’s used on a registered sidebar id ‘sidebar-1’ or ‘sidebar-2’?
- How can I include tags in wordpress search without a plugin
- How can you disable search for non-members on your WordPress website.
- Search results template listing all posts
- My function echos only “array”
- PHP: Why does my code work in index.php but not a widget?
- Search bar for page that searches only particular page IDs
- Limit Search Queries per IP per Day
- List of child pages fetch next results at link click
- Sidebar current menu item for parent
- Select All not working in a WordPress search filter
- Search in particular category in wordpress
- Different layout on search page depending on category post
- Search box background on a different page template
- Search through documents folder
- split searchresults into different topics?
- How to refresh a template page on WordPress in 3 seconds – easiest method?
- echo vs output variable [closed]
- Search results always returns “No results” no matter what
- Dynamically added text at bottom of article – non searchable by PHP code
- Woocommerce – Include custom user meta in order ‘filter by registered customer’ Ajax search
- Product Search in search.php
- WPML posts_joins on translated items
- Including product categories (product_cat taxonomy) title and description in search query
- How can I change text on my SearchWP search results page, as this is not an editable page in WordPress?
- How to improve the performance when using a flat-file dataset and PHP for implementing advanced search function?
- How to allow searching a custom meta key in admin list table?