I’ve created a custom post type portfolio and a taxonomy of course.

function taxonomies_portfolio() {
    $labels = array(
        'name'              => _x( 'Portfolio categories', 'taxonomy general name' ),
        'singular_name'     => _x( 'Portfolio categories', 'taxonomy singular name' ),
        'search_items'      => __( 'Query portfolio categories' ),
        'all_items'         => __( 'All portfolio categories' ),
        'parent_item'       => __( 'Parent category' ),
        'parent_item_colon' => __( 'Parent category:' ),
        'edit_item'         => __( 'Edit portfolio category' ), 
        'update_item'       => __( 'Update portfolio category' ),
        'add_new_item'      => __( 'Add Edit portfolio category' ),
        'new_item_name'     => __( 'New portfolio category' ),
        'menu_name'         => __( 'Categories' ),
    );
    $args = array(
        'labels' => $labels,
        'hierarchical' => true,
        'rewrite' => true
    );
    register_taxonomy( 'portfolio_category', 'portfolio', $args );
}
add_action( 'init', 'taxonomies_portfolio', 0 );

Is it possible to create 1 template file to display all items of a single category? I’ve tried to create a taxonomy.php but without success. What is the correct template name to work with?

2 Answers
2

According to the WordPress Codex page on Template Hierarchy, you create a template file with the name of taxonomy-portfolio_category.php. WordPress will use that to display the archive for that taxonomy. You can also use taxonomy-portfolio_category-{term_name}.php to create templates for specific terms in your taxonomy.

Leave a Reply

Your email address will not be published. Required fields are marked *