we use an ACF textual content subject to manually add a textual content string which is then used to tug in associated posts which have the identical core tag, i.e., when the ACF meta subject worth is ‘example-string’, all posts tagged with ‘example-string’ might be proven on the web page.
We even have a customized put up kind known as ‘Articles’ and a customized taxonomy known as ‘Article Tags’ and we’re making an attempt to test for the presence of an ‘article_tag’ utilizing the identical ACF subject that we use to test core tags. We have to do that as a result of the shortcode we use them with requires us return them as a comma separated record of ‘IDs’ to ensure that it to work.
We have tried to make use of wp_list_pluck however it’s the tax_query a part of the $args that appears to be inflicting the problem as a result of it makes use of a variable to incorporate the ACF meta subject worth.
Here is what I’ve acquired which presently returns nothing. It ought to return a comma separated record of put up ID(s) for any articles which have the article_tag that matches the get_field(‘mk_acf_sh_rel_tag’).
?php $mk_acf_sh_tag = get_field('mk_acf_sh_rel_tag'); if($mk_acf_sh_tag) { $mk_sh_articles_args = array( 'post_type' => 'article', 'tax_query' => array( array( 'taxonomy' => 'article_tag', 'subject' => 'slug', 'phrases' => $mk_acf_sh_tag ), ), ); $mk_sh_articles_query = new WP_Query($mk_sh_articles_args); $mk_sh_articles_query_ids = wp_list_pluck($mk_sh_articles_query->posts,'ID'); $mk_sh_articles_query_ids_string = implode(',', $mk_sh_articles_query_ids); if($mk_sh_articles_query->have_posts()): { echo do_shortcode('[post_block_shortcode post_ids="'.$mk_sh_articles_query_ids_string.'"]'); } endif; wp_reset_postdata(); } ?