分类.php=>下一页打开索引.php



我有类别.php文件,当我们打开类别链接时它工作正常。但是在类别.php中,当我单击"下一页"链接时,它会打开索引.php而不是类别的下一页.php。这是我的一些类别.php代码:

<?php
if (is_category( )) {
    $cat = get_query_var('cat');
    $yourcat = get_category ($cat);
    $CAT=$yourcat->slug;
} ?>
<?php query_posts("category_name=$CAT&showposts=1&order=ASC"); ?>
<?php while (have_posts()) : the_post(); ?>
.
.
.
<?php endwhile;?>
<?php posts_nav_link(); ?> 

和索引.php代码:

<?php query_posts('category_name=new_publish'); ?> <?php while (have_posts()) : the_post(); ?>
.
.
.
<?php endwhile;?>

完全删除这部分代码。不需要在类别.php模板上自定义循环。

if (is_category( )) {
    $cat = get_query_var('cat');
    $yourcat = get_category ($cat);
    $CAT=$yourcat->slug;
} ?>
<?php query_posts("category_name=$CAT&showposts=1&order=ASC"); ?>
嗨,

像这样使用这可能对你有用

<?php
if (is_category( )) {
    $cat = get_query_var('cat');
    $yourcat = get_category ($cat);
    $CAT=$yourcat->slug;
} ?>
<?php $pos_loop = query_posts('post_type' => "post","category_name"=>$CAT,"order"=>"ASC","orderby"=>"date"); ?>
<?php while ($pos_loop -> have_posts()) : $pos_loop -> the_post(); ?>
.
.
.
<?php endwhile;?>
<?php posts_nav_link(); ?> 

最新更新