我正在使用一个小的快捷码输出一个按几十年排列的电影标题列表。decades
是我的自定义分类法,术语如下1930s
1940s
等
以下是我的短代码:
[fashionfilms type=fashionfilms tax=decades]
下面是如何解析该短代码:add_shortcode(\'fashionfilms\', \'cw_output_fashion_films\');
function cw_output_fashion_films($atts){
$post_type = $atts[\'type\'];
$tax = $atts[\'tax\'];
$tax_terms = get_terms($tax);
if ($tax_terms) {
echo "<ul>";
foreach ($tax_terms as $tax_term) {
$args=array(
\'post_type\' => $post_type,
"$tax" => $tax_term->slug,
\'post_status\' => \'publish\',
\'posts_per_page\' => -1,
\'ignore_sticky_posts\'=> 1
);
$my_query = null;
$my_query = new WP_Query($args);
if( $my_query->have_posts() ) {
echo "<li class=\'letter\'>" . $tax_term->name . "</li>";
while ($my_query->have_posts()) : $my_query->the_post(); ?>
<li><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></li>
<?php
endwhile;
}
wp_reset_query();
} //end foreach loop
echo "</ul>";
}
}
问题是我的条目输出量增加了一倍。要查看翻倍的内容,请查看我的实时链接here.
以下是我的页面模板代码:
<div class="span9">
<?php while ( have_posts() ) : the_post(); ?>
<div <?php post_class(); ?>>
<h1><?php the_title();?></h1>
<div class="content">
<?php the_content() ?>
</div>
</div><!-- /.post_class -->
<?php endwhile; ?>
<?php bootstrapwp_content_nav(\'nav-below\');?>
</div><!-- /.span9 -->
我做错了什么?我怎样才能解决这个问题?