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 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.

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 ?

share|improve this question

1 Answer 1

up vote 3 down vote accepted

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
share|improve this answer
    
thanks, this seems like it should work (except you are missing a quote), but still nothing for me.. Could it have anything to do with the singular name? –  zac May 30 '11 at 20:20
    
i figured it out.. register_post_type (which I forgot to include in my question) is called portfolio and I needed to use that and not the name from the labels array –  zac May 31 '11 at 11:39
    
Ah - my bad, I just assumed you'd called it Photos! Anyway, glad you sorted it. –  anu May 31 '11 at 11:42

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.