我必须列出来自Wordpress自定义帖子类型的所有帖子,并只显示通过自定义分类标准创建的标题及其各自的类别。我的代码在这里,我在分类法上遇到了一些问题。在Wordpress中列出所有帖子和相应的分类标准
<?php
$args = array(
'post_type' => 'books',
'posts_per_page' => -1);
$myposts = get_posts($args);
$terms = get_the_terms($post->ID , 'category');
foreach ($myposts as $post) : setup_postdata($post); ?>
<h1><?php echo the_title(); ?></h1>
<p>Category: <?php echo $term->name; ?></p>
<?php endforeach;
wp_reset_postdata();?>
谢谢@ nerijus-masikonis,但它没有渲染类别。 =( –