2012-11-27 31 views
0

我試圖讓頁面顯示某個類別。這種特殊的網頁是「創意和想法」獲取這個category.php來顯示某個類別! (WordPress的)

我想寫寫我的意見和想法了幾行,並在其下,顯示與ID 16類別名爲「思考」

我將如何去?

這裏是我的主題category.php:

<?php get_header(); ?> 

<div id="wrap"> 
<!-- Main Content--> 
    <img src="<?php bloginfo('template_directory');?>/images/content-top.gif" alt="content top" class="content-wrap" /> 
    <div id="content"> 
     <!-- Start Main Window --> 
     <div id="main"> 
      <?php global $query_string; $catnum_posts = get_option('theme_catnum_posts') ; 
     query_posts($query_string . "&showposts=$catnum_posts&paged=$paged&cat=$cat"); ?> 
      <?php if (have_posts()) : while (have_posts()) : the_post(); ?> 

       <?php include(TEMPLATEPATH . '/includes/entry.php'); ?> 

      <?php endwhile; ?> 

       <?php if(function_exists('wp_pagenavi')) { wp_pagenavi(); } 
       else { ?> 
        <?php include(TEMPLATEPATH . '/includes/navigation.php'); ?> 
       <?php } ?> 

      <?php else : ?> 
       <?php include(TEMPLATEPATH . '/includes/no-results.php'); ?> 
      <?php endif; wp_reset_query(); ?> 
     </div> 
     <!-- End Main --> 

<?php get_sidebar(); ?> 

我試圖改變:

query_posts($query_string . "&showposts=$catnum_posts&paged=$paged&cat=$cat"); ?> 

query_posts($query_string . "&showposts=$catnum_posts&paged=$paged&cat=16"); ?> 

但是它沒有工作..

有何想法?

+0

$ query_string解析爲什麼?另外,如果您在此之前有任何其他查詢,則需要在query_posts()之前執行wp_reset_query() –

回答

0

類別頁面上的全局$query_string幾乎可以肯定已經定義了cat參數,這可能是爲什麼它忽略了您的cat=16。根據Kai的建議,我也會做一個新的query_posts,並致電wp_reset_query。試試這個循環:

<?php $catnum_posts = get_option('theme_catnum_posts') ; 
    wp_reset_query(); 
    $cat = 16; 
    query_posts("&showposts=$catnum_posts&paged=$paged&cat=$cat"); ?> 
     <?php if (have_posts()) : while (have_posts()) : the_post(); ?> 

      <?php include(TEMPLATEPATH . '/includes/entry.php'); ?> 

     <?php endwhile; ?> 
相關問題