Query multiple custom post types in single loop
-
Hello,
I’m aware there a few other threads on this topic but I’m afraid I can’t make any sense of them, so apologies for the duplication.
I have three custom post types running, in addition to ‘posts’. I want to run a loop that pulls all posts categorised under a particular category (bulletin), but I can only get it query a single post type.
This is the code I have, which works for one, but I’ve not managed to successfully adapt it to query more than one post type.
<?php query_posts('post_type=post&cat=3&showposts=5'); ?> <?php while ( have_posts() ) : the_post(); ?> <div class="post_type"> <?php if ( 'post' == get_post_type() ) : ?>FEATURE<?php endif; ?> <?php if ( 'report' == get_post_type() ) : ?>REPORT<?php endif; ?> <?php if ( 'opinion' == get_post_type() ) : ?>OPINION<?php endif; ?> <?php if ( 'bookmark' == get_post_type() ) : ?>BOOKMARK<?php endif; ?> </div> <a href="<?php the_permalink(); ?> "><?php the_title(); ?></a> <div class="excerpt"> <?php echo get_the_excerpt(); ?> </div> <?php endwhile; ?>
Any help would be much appreciated!
Thanks
Viewing 7 replies - 1 through 7 (of 7 total)
Viewing 7 replies - 1 through 7 (of 7 total)
- The topic ‘Query multiple custom post types in single loop’ is closed to new replies.