Skip to content

Instantly share code, notes, and snippets.

@philippkuehn
Created May 7, 2015 11:34
Show Gist options
  • Save philippkuehn/ca2d375841c585e89338 to your computer and use it in GitHub Desktop.
Save philippkuehn/ca2d375841c585e89338 to your computer and use it in GitHub Desktop.
search a custom post type page
<?php
$args = array(
'posts_per_page' => 10,
'post_type' => 'your_custom_post_type',
'post_status' => 'publish',
's' => get_search_query()
);
$query = new WP_Query($args);
if ($query->have_posts()) :
while ($query->have_posts()) : $query->the_post();
// loop
endwhile;
endif;
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment