Skip to content

Instantly share code, notes, and snippets.

@raewrites
Created January 16, 2015 05:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save raewrites/ec28aa8540ca04d4d211 to your computer and use it in GitHub Desktop.
Save raewrites/ec28aa8540ca04d4d211 to your computer and use it in GitHub Desktop.
Look for Category
<?php
function my_function() {
if ( is_category( 'category-slug' ) && $query->is_main_query() ) {
$query->set( 'post_type', 'custom_post_type' );
return $query;
}
}
add_action( 'pre_get_posts', 'my_function');
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment