我想我的分类页面上的循环有问题。在我需要permalink的代码的任何部分(特别是侧栏上),它总是返回分类循环第一项的链接,但正确的是当前页面的链接。
这是我的分类页面代码:
<?php get_header(); ?>
<div id="header_titulo">
<div class="container">
<?php $term_global = get_term_by(\'slug\', get_query_var(\'term\'), get_query_var(\'taxonomy\')); ?>
<h1 class="esquerda"><a title="Voltar" href="<?php echo get_bloginfo(\'url\') . \'/colecoes\'; ?>">< Voltar</a></h1>
<h1 class="direita_voltar"><?php echo $term_global->name; ?></h1>
</div>
<div class="hr"></div>
</div>
<div id="content-container" class="center">
<div class="sidebar esquerda">
<?php if (have_posts()){ ?>
<?php while (have_posts()){ ?>
<?php the_post(); ?>
<?php } ?>
<?php } ?>
<?php rewind_posts(); ?>
<?php wp_reset_query(); ?>
<?php get_sidebar(\'colecoes\'); ?>
<?php wp_reset_query(); ?>
</div>
<div id="content" class="direita">
<?php
$args = array(\'post_type\' => \'colecoes\', \'paged\' => $paged, \'posts_per_page\' => 12, \'order\' => \'DESC\', \'taxonomy\' => \'categorias\', \'term\' => $term_global->slug);
$loop = new WP_Query($args);
$contagem = 0;
if (sizeof($loop->posts) >= 1){
echo "<ul class=\'listagem\'>";
while ($loop->have_posts()){
$loop->the_post();
$args = array(
\'post_type\' => \'attachment\',
\'numberposts\' => null,
\'post_status\' => null,
\'post_parent\' => $post->ID,
\'numberposts\' => 1
);
$attachments = get_posts($args);
if ($contagem == 2 || $contagem == 5 || $contagem == 8 || $contagem == 11 || $contagem == 14){
echo "<li class=\'sem_borda\'>";
}else{
echo "<li>";
}
if ($attachments) {
echo \'<a class="imagem" href="\' . get_bloginfo(\'url\') . \'/colecao/\' . $loop->post->post_name . \'" title="\' . get_the_title() . \'">\';
echo \'<div class="fotos">\';
the_thumb(get_the_title(),0,1,false);
the_thumb(get_the_title(),1,2,false);
echo \'</div>\';
echo \'</a>\';
}
echo \'<div class="box">\';
echo \'<p><a href="\' . get_bloginfo(\'url\') . \'/colecao/\' . $loop->post->post_name . \'" title="\' . get_the_title() . \'">\'.get_the_title().\'</a></p>\';
echo \'</div>\';
echo "</li>";
if ($contagem == 2 || $contagem == 5 || $contagem == 8){
echo \'<div class="hr colecao"></div>\';
}
$contagem = $contagem + 1;
}
echo "</ul>";
}else{
echo category_description();
}
?>
</div>
<div id="content" class="direita">
<div class="paginacao">
<?php wp_pagenavi(array(\'query\' => $loop)); ?>
<?php rewind_posts(); ?>
<?php wp_reset_query(); ?>
</div>
</div>
</div>
<?php get_footer(); ?>