Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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() {
    register_taxonomy(
        'portfolio_tag',
        'portfolio',
        array(
            '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(); ?> 

            <li>

                <?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(); ?>
                    </a>

                <?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(); ?>" />
                    </a>

                <?php } ?>

            </li>

        <?php endwhile; ?>

        </ul>

        <?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
add comment

2 Answers

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
add comment

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

share|improve this answer
add comment

Your Answer

 
discard

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.