I have setup a custom post types called boxes that works fine and uses the default category taxonomy.
I have written a get_query_var at the top of my category.php to detect cp-type=boxes in the url and if so it only displays posts in that category from the custom post type boxes.
This all works fine but i want a pretty url
ideally something like /boxes/category/fancy/
i have tried using this method:
function my_rewrite_rules($rules)
{
global $wp_rewrite;
$my_rule = array(
'^boxes/category/(.+)/' => '^category/' . $matches[1] . '?cp-type=boxes'
);
return array_merge($my_rule, $rules);
}
add_filter('page_rewrite_rules', 'my_rewrite_rules');
function my_query_vars($vars)
{
$my_vars = array(
'cp-type'
);
return array_merge($my_vars, $vars);
}
add_filter('query_vars', 'my_query_vars');
All this does is it throws a 404.