【发布时间】:2019-06-27 14:09:24
【问题描述】:
我需要使用 ACT 分类字段查询自定义帖子。我创建了这段代码:
我的分类 ACF 字段返回术语对象并允许多选,但此代码仅适用于最后选择的术语。我需要查询所有选定的术语。
<?php
$album_count = get_sub_field('album-count');
$album = get_sub_field('album-custom-category'); ?>
<?php foreach ( $album as $album ); ?>
<?php $the_query = new WP_Query(
array(
'post_type' => 'gallery',
'orderby' => 'date',
'posts_per_page' => 6,
'tax_query' => array(
array(
'taxonomy' => 'albums',
'field' => 'slug',
'terms' => array( $album->slug ),
),
),
)
);
?>
我的错误在哪里?
【问题讨论】:
标签: wordpress advanced-custom-fields