【发布时间】:2020-06-15 14:29:51
【问题描述】:
我在最新版本中使用acf pro 和wordpress。
我有一个灵活的内容字段,我想在其中显示某些事件。
显示的事件应由分类字段选择,其中可以通过复选框选择自定义后分类(位置)的多个条目(城市)。 (多选)
返回是一个分类对象。
我需要所选字段中的 slug 列表。
该列表应该是例如比如:“慕尼黑”、“伦敦”、
相关代码是
<?php
$locations = get_sub_field('select_locations');
$loop = new WP_Query(array(
'post_type' => 'events',
'posts_per_page' => 99,
'tax_query' => array(
array(
'taxonomy' => 'locations',
'field' => 'slug',
'terms' => array(
/* HERE SHOULD BE THE LIST */
)
)
)
));
?>
我尝试了几件事,但无法正常工作。 如果有人能帮我解决这个问题,我会很高兴。
非常感谢。
【问题讨论】:
标签: wordpress advanced-custom-fields custom-taxonomy