I am getting a list of categories for a custom post type project
using get_categories($args)
with the following arguments:
$args = array(
'type'=> 'project',
'orderby'=> 'name',
'order'=> 'ASC',
'hide_empty'=> 1,
'hierarchical'=> 1,
'exclude'=> '',
'include'=> '',
'number'=> '',
'taxonomy'=> 'category',
'pad_counts'=> false
);
Then I am iterating through the categories and linking to the archive with the following code:
<li><a href="<?=get_category_link( $category->term_id ); ?>" title="<?php sprintf( __( "View all posts in %s" ), $category->name ); ?>"><?=$category->name?></a></li>
The problem is, the resulting link is like:
http://domain.com/category/example_cat
which results in in a 404, rather than:
http://domain.com/projects/category/example_cat
I know I could do an str_replace()
but it seems like there should be a proper way to do this, does anyone know how to ensure the category link is properly generated with the custom post type?
EDIT:
I am rewriting the slug in the custom post type declaration with 'rewrite' => array('slug' => 'projects')
/project/category/example_cat/
?/category/example_cat/
is the default format.'rewrite' => array('slug' => 'projects')