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 been at this now for about 12 hours I just don't know what I am doing.

My theme has a home page post display scroller which shows posts from a selected category. At the moment it is only showing normal posts.

Could someone please tell me how to make it show the custom type posts from that category aswell. The code for the scroller is:

<?php
function get_home_scroll( $cat_data ){ ?>

<?php
    wp_enqueue_script( 'tie-cycle' );

    $Cat_ID = $cat_data['id'];
    $Posts = $cat_data['number'];
    $Box_Title = $cat_data['title'];

    $cat_query = new WP_Query('cat='.$Cat_ID.'&posts_per_page='.$Posts); 
?>
        <section class="cat-box scroll-box">
            <div class="cat-box-title">
                <h2><?php echo $Box_Title ; ?></h2>
                <div class="stripe-line"></div>
            </div><!-- post-thumbnail /-->
            <div class="cat-box-content">

                <?php if($cat_query->have_posts()): ?>
                <div  id="slideshow<?php echo $Cat_ID ?>">
                <?php while ( $cat_query->have_posts() ) : $cat_query->the_post()?>
                    <div class="scroll-item">
                        <?php if ( function_exists("has_post_thumbnail") && has_post_thumbnail() ) : ?>         
                            <div class="post-thumbnail">
                                <a href="<?php the_permalink(); ?>" title="<?php printf( esc_attr__( 'Permalink to %s', 'tie' ), the_title_attribute( 'echo=0' ) ); ?>" rel="bookmark">
                                    <?php tie_thumb('',272,125); ?>
                                </a>
                            </div><!-- post-thumbnail /-->
                        <?php endif; ?>         
                        <h3><a href="<?php the_permalink(); ?>" title="<?php printf( esc_attr__( 'Permalink to %s', 'tie' ), the_title_attribute( 'echo=0' ) ); ?>" rel="bookmark"><?php the_title(); ?></a></h3>
                        <p class="post-meta">
                            <?php tie_get_time() ?>
                            <?php tie_get_score(); ?>
                        </p>
                    </div>
                <?php endwhile;?>
                <div class="clear"></div>
                </div>
                <div id="nav<?php echo $Cat_ID ?>" class="scroll-nav"></div>


                    <?php endif; ?>
            </div><!-- .cat-box-content /-->
        </section>
        <div class="clear"></div>


<?php } ?>
share|improve this question
2  
There doesn't appear to be anything post-type specific here. Are you sure your CPT has posts in $Cat_ID? –  vancoder Apr 30 '13 at 16:20
    
To correct myself - your query will be defaulting to post. –  vancoder Apr 30 '13 at 17:11
add comment

1 Answer

By using post_type parameter of WP_Query to specify all types of posts you want to get (or replace the array with 'any' to just get everything):

$my_custom_post_types = array( 'post', 'carrots' );
$args = array(
    'cat' => $Cat_ID,
    'posts_per_page' => $Posts,
    'post_type' => $my_custom_post_types
);
$cat_query = new WP_Query($args);

You'll need to change 'carrots' to the name of your custom post type.

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.