wp query – Custom post type loop with custom category filtering
Question
Is that category or custom taxonomy?
if this is a category, then try this one.
<?php
$loop = new WP_Query(
array(
'post_type' => 'portfolio',
'posts_per_page' => 50,
'category__in' => array('8','9','10'), // your category ids
)
);
while ( $loop->have_posts() ) : $loop->the_post();
?>
<div class="half-column">
<h2><?php the_title(); ?></h2>
</div>
<?php endwhile;
wp_reset_postdata();
?>
Or if this custom taxonomy, try this one
<?php
$loop = new WP_Query(
array(
'post_type' => 'portfolio',
'posts_per_page' => 50,
'tax_query' => array(
array (
'taxonomy' => 'yourTaxonomy',
'field' => 'slug', //type, id or slug
'terms' => 'yourTermSlug',
)
),
)
);
while ( $loop->have_posts() ) : $loop->the_post();
?>
<div class="half-column">
<h2><?php the_title(); ?></h2>
</div>
<?php endwhile;
wp_reset_postdata();
?>
let me know the update.
Thank You
0
2 months
2022-06-23T16:07:40-05:00
2022-06-23T16:07:40-05:00 0 Answers
0 views
0
Leave an answer