WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have the following code in my Functions.php file to create a custom taxonomy and post type. And I have created a series of posts within this post type and attached tags to them.

add_action( 'init', 'create_my_post_types' );

function create_my_post_types() {

register_post_type('portfolio', array(
    'label' => __('Portfolio'),
    'singular_label' => __('Portfolio'),
    'public' => false,
    'show_ui' => true,
    '_builtin' => false,
    '_edit_link' => 'post.php?post=%d',
    'capability_type' => 'post',
    'hierarchical' => false,
    'rewrite' => array('slug' => 'work', 'with_front' => false),
    'query_var' => 'portfolio',
    'supports' => array('title', 'thumbnail'),
    'menu_position' => 5


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

function create_pc_db_taxonomies() {
            'hierarchical' => true,
            'label' => 'Portfolio Tags',
            'rewrite' => array('slug' => '', 'with_front' => false)

I have created a custom loop on my home page and successfully shown my posts from this type which shows they work, however when viewing the taxonomy archive I just get the message that no posts could be found... It is finding the correct template to use just not seeing posts attached to that taxonomy. Here is the code for the Taxonomy.php

<?php if (have_posts()) : ?>

        <ul id="gallery" class="portfolio-list clearfix">   

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


                <?php if ( has_post_thumbnail() ) { ?>

                    <a class="fancybox" title="<?php the_title(); ?>" rel="bookmark" href="<?php
                    $attachments = get_children( array('post_parent' => get_the_ID(), 'post_type' => 'attachment', 'post_mime_type' =>'image') );
                    foreach ( $attachments as $attachment_id => $attachment ) {
                        echo wp_get_attachment_url( $attachment_id, 'medium' );
                    } ?>">
                        <?php the_post_thumbnail(); ?>

                <?php } else { ?>

                    <a class="fancybox" title="<?php the_title(); ?>" rel="bookmark" href="http://dummyimage.com/640x480/333/fff&text=x">
                        <img src="http://dummyimage.com/300x300/333/fff&text=x" alt="<?php the_title(); ?>" />

                <?php } ?>


        <?php endwhile; ?>


        <?php else : ?>

        <p><?php _e('Sorry, no posts matched your criteria.'); ?></p>

        <?php endif; ?>

Any ideas why this is not working? Thanks

share|improve this question
Whoever down-voted his question, be sure to leave him a comment as to what you are thinking he could have done to improve his question, please. – MikeSchinkel Nov 9 '10 at 18:56
It was even a full discussion that leaded Cameron to find the error in the end. – hakre Nov 9 '10 at 19:54

Discovered the problem. The public parameter was set to false!

share|improve this answer
yeah that would do it. also remember that custom post types don't currently get archive pages for free. That will come in 3.1. – curtismchale Nov 9 '10 at 19:38
That sounds silly what if someone doesn't want an archive page? I much prefer creating a page and a custom template with loop. That was one of the coolest things about Custom Post Types. – Cameron Nov 10 '10 at 21:30

This also stumped me set "public" => "true" in register_taxonomy() in order for WP to access your taxonomy template.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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