Displaying category archive of custom post types

You can force use of your template for categories with the category_template filter:

function wpa57439_category_template( $templates="" ){
    if( !is_array( $templates ) && !empty( $templates ) ) {
        $templates = locate_template( array( 'archive-actors.php', $templates ), false );
    } 
    elseif( empty( $templates ) ) {
        $templates = locate_template( 'archive-actors.php', false );
    }
    else {
        $new_template = locate_template( array( 'archive-actors.php' ) );
        if( !empty( $new_template ) ) array_unshift( $templates, $new_template );
    }
    return $templates;
}
add_filter( 'category_template', 'wpa57439_category_template' );

adapted from Filter Hierarchy in codex.

Leave a Comment