WordPress.org

Support

Support » Themes and Templates » [Resolved] query posts from multiple post types

[Resolved] query posts from multiple post types

  • Hello All,

    I was wondering if someone could help me, i would like to query the latest 5 post from my 3 custom post types and woocommerce. but i would like there to always be 5 posts all together at any given time. I would really appreciate the help.

    Thank you.

Viewing 2 replies - 1 through 2 (of 2 total)
  • If anyone was wondering i found the solution in another post on this forum

    Here it is :

    <?php query_posts( array(
         'post_type' => array( 'post-type', 'post-type', 'post-type', 'post-type' ),
         'cat' => 3,
         'showposts' => 5 )
         ); ?>
    		<?php while ( have_posts() ) : the_post(); ?>
    
    		<div class="post_type">
    
    		<?php if ( 'post-type' == get_post_type()  ) : ?>FEATURE<?php endif; ?>
    		<?php if ( 'post-type' == get_post_type()  ) : ?>REPORT<?php endif; ?>
    		<?php if ( 'post-type' == get_post_type()  ) : ?>OPINION<?php endif; ?>
    		<?php if ( 'post-type' == 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; ?>

    dont forget to replace post type with your custom post type name

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘[Resolved] query posts from multiple post types’ is closed to new replies.