I have a custom post type registered as publication and a custom taxonomy registered as publication_category.

The post type's slug is publication and the taxonomy slug is publication/category.

The reason I have it set up like that is to get these urls

example.com/publication/ - Archive
example.com/publication/post-name - Single
example.com/publication/category/category-name - Category Archive

The problem is that when I go to this url example.com/publication/category/category-name the post_type is not set so it uses the default archive template.

Is there a way without passing in ?post_type=publication that I can set the post_type to publication so it uses the publication archive template?


It turned out that the post_type was being set but for some reason it would not load the appropriate archive template. I'm suspect it has something to do with the way my post type and custom taxonomy are set up.

Here is a solution I came up with. I'm open to suggestions.

function custom_template_redirect() {
    if (is_archive() && get_post_type() != '') {
        $file = TEMPLATEPATH . '/archive-' . get_post_type() . '.php';
        if ( file_exists( $file ) ) {
            include ($file);
add_action('template_redirect', 'custom_template_redirect');

Your Answer

By clicking "Post Your Answer", you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.