WP Query Based On Particular Taxonomy/Category From ACF Taxonomy Field

Share Now

$posts_per_page = get_field('posts_per_page'); 
$g_terms = get_field('posts_ctg');
//create term array
foreach( $g_terms as $g_term ){
 $term_ID = $g_term->term_id;
 $post_ctgs[] = $term_ID;
}


//query
$article_args = array(
    'post_type' => 'post',
    'posts_per_page' => $posts_per_page,
    'category__in' => $post_ctgs,
    'post__not_in' => array($f_post_id),
);
$articles = new WP_Query($article_args);
while ($articles - > have_posts()): $articles - > the_post();

Picture of Nahid Mahamud

Nahid Mahamud

Web Developer | Graphic Designer | WordPress & Woo-commerce Expert