I've created a custom post type and taxonomy for a portfolio loop:
// Portfolio CPT
function portfolio_cpt() {
$labels = array(
'name' => _x( 'Potfolio Items', 'post type general name' ),
'singular_name' => _x( 'Portfolio item', 'post type singular name' ),
'menu_name' => 'Portfolio Items'
);
$args = array(
'labels' => $labels,
'description' => 'Portfolio items',
'public' => true,
'menu_position' => 5,
'supports' => array( 'title', 'editor', 'thumbnail', 'excerpt', 'comments' ),
'has_archive' => true,
);
register_post_type( 'portfolio', $args );
}
add_action( 'init', 'portfolio_cpt' );
function portfolio_tax() {
$labels = array(
'name' => _x( 'Portfolio Categories', 'taxonomy general name' ),
'singular_name' => _x( 'Portfolio Category', 'taxonomy singular name' ),
'menu_name' => __( 'Portfolio Categories' ),
);
$args = array(
'labels' => $labels,
'hierarchical' => true,
);
register_taxonomy( 'portfolio_category', 'portfolio', $args );
}
add_action( 'init', 'portfolio_tax', 0 );
This bit of code is in the single post page, so when I click a category, it sends me to the category archive page:
<?php
$taxonomy = 'portfolio_category';
$terms = get_terms($taxonomy);
if ( $terms && !is_wp_error( $terms ) ) :
?>
<ul>
<?php foreach ( $terms as $term ) { ?>
<li><a href="<?php echo get_term_link($term->slug, $taxonomy); ?>"><?php echo $term->name; ?></a></li>
<?php } ?>
</ul>
<?php endif;?>
And then created a custom archive file called archive-portfolio.php
to list the posts relating to a specific category.
The problem is, it seems to be still using the default archive template, meaning I can't edit/style the page
Any ideas?