I am creating this custom post(which is some sort of image gallery). Well each custom post also have this taxonomy, which works as a category type/post type.

My question is, how do I create a custom template page, and in that loop the data, which corresponds to the taxonomy? What should the file be named?


$gallery_labels = array(
    'name' => _x('Photo gallery', 'post type general name'),
    'singular_name' => _x('Gallery', 'post type singular name'),
    'parent_item_colon' => ''

$gallery_args = array(
    'labels' => $gallery_labels,
    'public' => true,
    'publicly_queryable' => true,
    'show_ui' => true,
    'query_var' => true,
    'capability_type' => 'post',
    'supports' => array('title','thumbnail')
register_post_type('gallery', $gallery_args);


add_action( 'init', 'gallery_taxonomies', 0);

function gallery_taxonomies(){
            'hierarchical'=> true,
            'label' => 'Photo Types',
            'singular_label' => 'Photo Type',
            'rewrite' => true

Lets say I have these taxonomies

name  descripton  slug
A         ...      a
B         ...      b
C         ...      c

and then my custom post which uses the taxonomies (category style)

thumnail    title      phototype
1.png       one a          a
2.png       two a          a
3.png       one b          b
4.png       one c          c
5.png       two c          c

so if I go to the page

myurl.com/phototype=a it should show

  • one a
  • two a
  • You should call your post type gallery. That name is used internally by Wordpress. Commented May 7, 2015 at 12:43
  • Thanks for the little tip, just called it mygallery instead.
    – Sigils
    Commented May 7, 2015 at 12:48
  • Your talking about taxonomy archive pages?
    – Tom J Nowell
    Commented May 7, 2015 at 12:52
  • Hi Tom, I don't know what a taxonomy archive page is, but I am asking to get all the "custom post" corresponding to the selected garegory(taxonomy). But I actually believe that 'taxonomy archive pages' is what I am searching for.
    – Sigils
    Commented May 7, 2015 at 13:00

1 Answer 1


I figured out the answer,

since I am registering my taxonomy as phototype I simply have to create a file named taxonomy-phototype.php and inside that I will get the data by looping like I normally would in wordpress

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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