Skip to content

Instantly share code, notes, and snippets.

@brianpurkiss
Created May 13, 2019 14:06
Show Gist options
  • Save brianpurkiss/142b854aeae639dc5a9459de21615331 to your computer and use it in GitHub Desktop.
Save brianpurkiss/142b854aeae639dc5a9459de21615331 to your computer and use it in GitHub Desktop.
Search Just a Custom Post Type
<?php /*
Search just a custom post type using WordPress' native search.
Uses Boostrap classes.
Swap out "CustomPostTypeHere" for your custom post type slug.
*/ ?>
<form class="form-inline" action="<?php echo home_url( '/' ); ?>">
<div class="form-group mx-sm-3 mb-2">
<label for="cptsearch" class="sr-only">Search</label>
<input type="search" class="form-control" id="cptsearch" name="s" placeholder="Search">
</div>
<input type="hidden" name="post_type" value="CustomPostTypeHere">
<button type="submit" class="btn btn-primary mb-2">Search</button>
</form>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment