How to loop custom post_type from (a) specific category(ies)?
Question
I’m using this code which works really fine to list quite everything I need as Featured image and title, from my custom posts "portfolio".
<?php
$args = array(
'posts_per_page' => 5000,
'offset' => 0,
'orderby' => 'title',
'order' => 'ASC',
'post_type' => 'portfolio',
'post_status' => 'publish',
'suppress_filters' => true );
$posts = get_posts($args);
foreach ($posts as $post) :
?>
<div class="grid-item">
<a href="<?php the_permalink();?>">
<div class="grid-image <?php echo get_the_category()?>">
<h2 class="grid-title"><?php echo the_title();?></h2>
<?php echo the_post_thumbnail(array(360,360));?>
</div>
</a>
</div>
But now, I’d like to list only posts from a choosen category. I tried to add these following terms in args but nothing seems to work.
'category' => 'category-slug',
'category' => category-id,
Any advice on this ? Many Thanks
0
2 years
2020-12-17T17:10:22-05:00
2020-12-17T17:10:22-05:00 0 Answers
8 views
0
Leave an answer