Los Angeles Front End Developer
PSD to Wordpress, HTML, CSS & jQuery.


If you have a custom post type with a custom taxonomy, you probably want an archive page that will pull in only the posts associated with each term, but without having to know each term in advance – ie. You want a category.php template for your custom taxonomy.

Learning the file name was easy (taxonomy-taxonomyname.php eg. taxonomy-hairstyles.php) but getting the query in there was @#$%^ hard.

So here it is – if you want a category.php (catchall archive template) for yoru custom taxonomy terms user this

<?php $term = get_term_by( ‘slug’, get_query_var( ‘term’ ), get_query_var( ‘taxonomy’ ) ); ?>

<?php if (have_posts()) : ?>
<?php while (have_posts()) : the_post(); ?>

// Your individual post formatting here
<article class=”post”>
<a href=”<?php the_permalink();?>”>
<h3><?php the_title();?></h3>
<?php the_content();?>

// end your individual post formatting
<?php endwhile; ?>
<?php endif; ?>