just add
<input type="hidden" name="post_type" value="post type name" />
to your search form and obviously replace post type name with your custom post type name.
and to make sure that only your custom post type return as results add:
function mySearchFilter_0987($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','mySearchFilter_0987');
Hope this helps
Related Posts:
- Use template_include with custom post types
- Combining Multiple Taxonomies in one URL
- Taxonomy term in permalink
- How to give a CPT (custom post type) a date based url
- how can I create a calendar for a cpt, using get_calendar or other
- Numbering sections and block-level elements in wpautop(); WordPress as CMS for long-form writing;
- Modify custom post type rewrite rules in a separate function
- get_edit_post_link() not working as expected when passed id in plugin
- ‘No pages found’ in Dashboard after registering custom taxonomy
- Why is wp_is_post_revision always false?
- Change page /2 to /transcript with a Rewrite
- Custom Post Type ‘hierarchical’ Help!
- Issue with saving custom post type when editor is removed
- How would I leverage custom Taxonomies in this scenario?
- Using custom post types in submenu + custom title
- Dynamic dropdown custom post list based on dropdown selection
- How to display recent posts added in custom post types
- Excluding post type from WordPress link builder
- Multiple Content Block
- Creating a function that receives the taxonomy terms that have been changed in a custom post type
- Thumbnails on next/previous links in custom post type single.php
- Dynamic iCal generator outside/inside wordpress
- 2 different post->IDs for single page load only in Firefox
- How to show custom (checkbox) field value in admin post list?
- Display custom post types with custom date field value (before today) & order by custom date field
- Remove All, Published and Trashed Post Views in Custom Post Type
- Using pre_get_posts to filter one loop in a multiloop archive
- How to quickly reorder posts in the admin panel that will persist for the wp-api
- Podcast Guest List
- Remove Slug From Custom Post Type URL?
- Custom post type and permalink issue
- Update post terms with custom taxonomy
- Show custom post type filtered by category
- Displaying Page as Custom Post type landing Page
- Get custom post type list for every category shortcode
- create a subcatagory for a custom post type and out put url as posttype/subcategory/item
- How do I display the taxonomy term alongside the post type post title?
- Rewrite Question Mark in Post Template to Make it Pretty URL
- Exporting individual custom post type post for deployment?
- Custom Post, set object Taxonomy terms in plugin
- CPT Template Not Showing – Getting 404
- Rewrite Endpoints and CPTs – How to use in a plugin
- How to remove Trash link from custom post type
- Can I display custom post types in home.php or need page template?
- Sort posts in loop by the WooCommerce Membership of the author
- return only the first two terms of custom post
- Loop through custom posts by taxonomy and display the titles in a list, it is repeating 8 times
- retrieve permalinks of posts inside custom post type by using post ID
- Can I change my post type to anything and my site still work?
- How to change base in tag URL for custom post type, to not use “Custom Structure” set in Permalinks setting?
- Combine multiple CPT names to create valid permalinks
- Get parent category(taxonomy) ID from single template of a custom post type
- Dynamic CPT / Taxonomy
- Custom posts of one type have disappeared from admin. Still appear on site [closed]
- Custom post types sorting admin columns nothing found
- Custom Post Type: Search Results – Template for no results
- Different structure/content for posts from a custom post type
- delete duplicate meta_value with same post_id
- Custom post type draft use wrong template
- Custom Taxonomy Filter Issues
- CPT archive page – show one post from each taxonomy term
- Subpages Permalinks Issues
- Custom post-type custom query – show all posts
- Event Archive by Month
- Display custom post type from template
- Change Text in Admin Panel
- Limiting actions only to edit.php page for specific custom post type
- Archive page of taxonomy returns a 404 error
- Adding a location field to buddypress activity
- How to Grab Anime info using Jikan API and fill the value in Metabox
- Is there a way to display a custom post type menu item as “users” submenu?
- How to generate auto shortcode for custom post type same as Elementor Template?
- Query a Custom Post Type using SELECT that has ACF fields to compare dates
- I want to create a metabox under custom taxonomy
- How to output and alert message when updating a post
- Sql Update CPT from publish to draft and particular custom field
- Custom post type and custom page name
- Post list displaying wrong in Chrome and Firefox
- Custom post type meta fields missing on save_post_type
- Custom Post Type with Custom Taxonomy in Bootstrap 4 Accordion
- Hierarchical Custom Post Type Walker?
- Changing menu label to post name for custom post type
- How to display user-defined / custom post in wordpress?
- Featured image in custom post is being disabled
- Remove Custom Capability
- How to set class to “current-page” on the currently viewed single post within a CPT
- Is it possible to add query parameters on the archive page?
- Permalinks when using Custom Post Type with static page for archive
- Custom sortable pages on custom post type
- How do I add custom fields to posts without having to manually add everytime I post?
- How to change permalinks to taxonomy and post type’s posts
- Custom Catagory not found
- Query Only Show Text on Posts With Certain Taxonomy Tag
- Remove ?preview=true from the address of custom post types
- Custom Post Type to Upload Images
- Hierarchical Custom Post Types
- Custom Post type easy way for editors
- ACF select box css color change
- WordPress custom field sorting, weird behavior: the latest post is at the end
- Limit taxonomy terms added to a custom post type