Skip to content

Instantly share code, notes, and snippets.

View gambl's full-sized avatar

Matthew Gamble gambl

  • BBC
  • United Kingdom
View GitHub Profile
@nerrad
nerrad / categorycptrewrite.php
Created October 28, 2012 17:52
Have category archive pages display only posts in a certain custom post type
/**
* This could be extrapolated and used for tags or any other taxonomy really.
*/
add_action('init', 'category_cpt_rewrites');
function category_cpt_rewrites() {
$custom_post_types = array('video', 'audio', 'photo', 'file'); //some example post types
foreach ( $custom_post_types as $post_type ) {
$rule = '^' . $post_type . '/category/(.+?)/?$';