Categories not working as expected with custom post type

I have a custom post type set up like:

    add_action('init', 'portfolio_register');

function portfolio_register() {
 $labels = array(
    'name' => _x('Photos', 'post type general name'),
    'singular_name' => _x('Portfolio Item', 'post type singular name'),
    'add_new' => _x('Add New', 'portfolio item'),
    'add_new_item' => __('Add New Portfolio Item'),
    'edit_item' => __('Edit Portfolio Item'),
    'new_item' => __('New Portfolio Item'),
    'view_item' => __('View Portfolio Item'),
    'search_items' => __('Search Portfolio'),
    'not_found' =>  __('Nothing found'),
    'not_found_in_trash' => __('Nothing found in Trash'),
    'parent_item_colon' => ''

    );

$args = array(
            'labels' => $labels,
            'public' => true,
            'publicly_queryable' => true,
            'show_ui' => true,
            'query_var' => true,
            //'menu_icon' => get_stylesheet_directory_uri() . '/article16.png',
            'rewrite' => true,
            'capability_type' => 'post',
            'hierarchical' => false,
            'menu_position' => 4,
            'taxonomies' => array('post_tag','category'),
            'supports' => array('title','editor','comments','trackbacks','revisions','custom-fields','page-attributes','thumbnail', 'excerpt', 'tags')
          ); 

It pulls all of the meta boxes in and everything fine for the single page.

Read More

On the home page I query from the Featured category like so :

Edit based on suggestion from spartacus

<?php 
    $args = array('category_name' => 'featured',
    'post_type' => array ('post','Photos'),
    'posts_per_page' => 20);

    $the_query = new WP_Query($args);
    while ($the_query->have_posts()) : $the_query->the_post();?>
        <?php //getImage(1); ?>
        <div class="featuredSlide">
            <a href="<?php the_permalink(); ?>">
            <img src="<?php bloginfo('template_url'); ?>/scripts/timthumb.php?src=<?php echo get_first_attachment() ?>&w=500&h=500&a=b&zc=1&q=80" alt="<?php the_title(); ?>" /></a>
        <?php the_title(); ?>
        </div>
    <?php endwhile; ?>

This works fine with normal posts I make but none of the posts in the custom post type category will be pulled into this featured category query. Can anyone see what is going wrong or have suggestions of what I should look for ?

Related posts

Leave a Reply

1 comment

  1. You need to add your custom post type to your WP_Query call:

    $args = array('category_name' => 'featured',
                  'post_type' => array ('post','Photos'),
                   posts_per_page' => 20);
    $the_query = new WP_Query($args);
    //continue with your loop