Search | Type: PHPSearch Form for CPT

To add a search form that searches only a particular post type, not your entire website.

<form id="cptsearch" action="<?php echo home_url(); ?>" method="get">
    <input name="s" type="text">
    <input name="post_type" type="hidden" value="POSTTYPENAME">
    <input id="searchsubmit" alt="Search" type="submit" value="Search">
</form>

Want results to use a different template than the normal search results? Add to functions.php:

function template_chooser($template) {
    global $wp_query;
    $post_type = get_query_var('post_type');
    if( $wp_query->is_search && $post_type == 'POSTTYPENAME' ) {
        return locate_template('page_POSTTYPENAME.php');
    }
    return $template;
}
add_filter('template_include', 'template_chooser');

Reference Links