【发布时间】:2017-09-29 03:37:32
【问题描述】:
我已经为它创建了一个自定义帖子类型和分类。我希望管理员能够在创建新的(页面)时选择他们想要在页面上显示的分类。我创建了一个自定义页面模板,并且有一个条件自定义字段,显示了该模板的可用分类管理。为此使用了自定义帖子类型 UI 和高级自定义字段插件。
<?php
// this one gets taxonomy custom field
$taxo = get_field('top_to_show');
// and from here on, it outputs the custom post type
$args = array(
'post_type' => 'top_item',
'post_status' => 'publish',
'tops' => $taxo
);
$lineblocks = new WP_Query( $args );
if( $lineblocks->have_posts() ) {
while( $lineblocks->have_posts() ) {
$lineblocks->the_post();
?>
<div>Custom post type layout html</div>
<?php
}
}
else {
echo '';
}
wp_reset_query(); ?>
现在,当我为页面的分类自定义字段选择“术语 ID”时,它根本不显示任何内容。当我选择“术语对象”时,它会显示来自所有分类法的所有帖子,而不是专门选择的帖子。
如何让它显示专门选择的分类帖子?
【问题讨论】:
标签: php wordpress custom-post-type advanced-custom-fields