2014-02-13 57 views
0

我有category.php文件,它在我們打開分類鏈接時工作正常。 但在類別.php中,當我點擊「下一頁」鏈接時,它會打開index.php而不是category.php的下一頁。 這裏是一個小的我category.php代碼:Category.php =>下一頁打開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(); ?> 

而且index.php的代碼:

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

你不需要在category.php – Banago

+0

確定一個自定義的循環。剛刪除第2行至第5行,category_name = $ CAT。沒有差別。 –

回答

0

完全刪除這部分代碼。您不需要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"); ?> 
+0

非常感謝。我必須儘快增加我對wordpress的瞭解:) –

0

嗨這樣使用,這可能爲你工作

<?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(); ?> 
相關問題