admin管理员组文章数量:1278983
This feels like an easy question but I just cannot get it to work.
I have a basic custom post loop displaying posts based on a taxonomy of location and can then manually change the terms to show posts tagged with the same term. All works fine.
What I am trying to do is change the manual term selection for an ACF taxonomy field called 'case_study_location', so what ever term is selected there then shows the correct posts in my loop. I have tried many different things but cannot get it to work.
Here is my loop
<?php
$loop = new WP_Query( array(
'post_type' => 'case_studies',
'posts_per_page' => 3,
'post_status' => 'publish',
'tax_query' => array(
array(
'taxonomy' => 'location',
'field' => 'slug',
'terms' => 'location-two'
)
) ) ); ?>
<?php while ( $loop->have_posts() ) : $loop->the_post(); ?>
<h3><?php the_title(); ?></h3>
<?php the_terms( $post->ID, 'location', 'categories: ', ' / ' ); ?>
<?php endwhile; wp_reset_query(); ?>
本文标签: custom post typesCreate loop from selected terms in ACF taxonomy field
版权声明:本文标题:custom post types - Create loop from selected terms in ACF taxonomy field 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741262867a2367944.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论