Category.php=>;下一页打开Index.php

Category.php=>;下一页打开Index.php,php,wordpress,Php,Wordpress,我有category.php文件,当我们打开一个category链接时,它可以正常工作。 但是在category.php中,当我单击“Next Page”链接时,它会打开index.php而不是category.php的Next Page。 下面是我的category.php代码的一小部分: <?php if (is_category( )) { $cat = get_query_var('cat'); $yourcat = get_category ($cat);

我有category.php文件,当我们打开一个category链接时,它可以正常工作。 但是在category.php中,当我单击“Next Page”链接时,它会打开index.php而不是category.php的Next Page。 下面是我的category.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 query_posts('category_name=new_publish'); ?> <?php while (have_posts()) : the_post(); ?>
.
.
.
<?php endwhile;?>

.
.
.
和index.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 query_posts('category_name=new_publish'); ?> <?php while (have_posts()) : the_post(); ?>
.
.
.
<?php endwhile;?>

.
.
.

将这部分代码全部删除。在category.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"); ?>
if(是_类()){
$cat=get_query_var('cat');
$yourcat=获取类别($cat);
$CAT=$yourcat->slug;
} ?>

您好,像这样使用可能适合您

<?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(); ?> 

.
.
.

您不需要category.phpOK中的自定义循环。刚刚删除了第2行到第5行,category_name=$CAT。不用客气,非常感谢。我必须尽快增加我对wordpress的了解:)