0

I need some tips for the code, I need to get 5 posts per every category, but this is show 5 post at all..

<div id="projects-carousel" class="owl-carousel">
<?php $query = new WP_Query( array( 'cat' => '1,3,4,5', 'posts_per_page' => 5) ); ?>
<?php while ( $query->have_posts() ) : $query->the_post(); ?>

<div class="project <?php foreach((get_the_category()) as $category){ echo 'catID-' . $category->term_id . ' ';} ?>">
    <?php the_content(); ?>
</div>

<?php endwhile; wp_reset_postdata(); ?>

Thanks for the answers!

  • This isn't possible with a single query. You need separate queries for each category. – Jacob Peattie Nov 5 '19 at 1:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.