【发布时间】:2014-02-28 22:55:36
【问题描述】:
我在使用自定义分类模板时遇到了一点问题。我继承了一个由其他人开发的网站,他们使用“类型”插件添加一些自定义分类法。
目标:
在 example-domain.com/people/harrison-ford 上拥有一个仅显示包含特定分类术语的帖子的存档模板
问题:
此代码引入了未选择分类的帖子。
这是我的完整代码:
<?php
$year = get_post_meta($post->ID, 'year', true);
$post_type = 'post';
$tax = 'people';
$tax_terms = get_terms( $tax );
if ($tax_terms) {
$args = array(
'post_type' => $post_type,
'people' => 'harrison-ford',
"$tax" => $tax_term->slug,
'post_status' => 'publish',
'posts_per_page' => -1,
'caller_get_posts'=> 1,
'orderby' => 'date',
'order' => DESC
);
$my_query = null;
$my_query = new WP_Query($args);
if( $my_query->have_posts() ) : ?>
<h2 class="wwNews"><?php echo $tax_term->name; ?> News</h2>
<?php while ( $my_query->have_posts() ) : $my_query->the_post(); ?>
<-- display stuff -->
<?php endwhile; // end of loop ?>
<?php endif; // if have_posts()
wp_reset_query();
}
?>
【问题讨论】:
标签: php wordpress archive taxonomy