2013-12-09 61 views
0

IM上的WordPress主題工作,一切順利,但我有這個問題顯示空消息WordPress的

我做一個PHP頁面「taxonomy.php」它顯示了自定義分類的帖子

問題我已如果我訪問空分類它讓我從其他分類一個帖子insted的顯示錯誤消息

的代碼我用它來顯示:

<?php 
get_header(); 
$temp = $wp_query; 
$wp_query = null; 
$wp_query = new WP_Query(); 
$wp_query->query('showposts=9&post_type=covers'.'&paged='.$paged); 
$term = $wp_query->queried_object; 

?> 

<div id="primary" class="site-content span12"> 
    <div id="content" class="entry-content" role="main"> 
     <?php 
$product_terms = wp_get_object_terms($post->ID, 'cover_category'); 
if(!empty($product_terms)){ 
    if(!is_wp_error($product_terms)){ 
    foreach($product_terms as $term){ 

     echo '<h4 style="color:#cb2027">'.$term->name.'</h4>'; 

     //Category Desciprion 
     echo '<h6 style="color:#cb2027">'.term_description($term->term_id, 'cover_category').'</h6>'; 
    } 
    } 
} 


?> 


<?php while ($wp_query->have_posts()) : $wp_query->the_post(); ?> 
<h5><?php the_title(); ?></h5> 
<?php endwhile; ?> 
<?php get_footer(); ?> 

現在,如果我訪問這個 http://localhost/wp/?cover_category=as - >這種分類有6個職位,並告訴他們正確的

如果我訪問這個http://localhost/wp/?cover_category=wawa - >這種分類瓦瓦有0帖子,並將其顯示來自帖子爲分類

回答

0

這是默認分類頁面的例子:

<?php if (have_posts()) : ?> 
      <?php while (have_posts()) : the_post(); ?> 
       <div style="height: 190px;"> 
        <?php if (has_post_thumbnail()) : ?> 
         <div class="thumb" style="float: left; width:170px;"> 
          <?php the_post_thumbnail('thumbnail'); ?> 
         </div>  
        <?php endif; ?> 
        <div style="float:left; width:475px;"> 
         <h1><?php the_title(); ?></h1> 
         <?php the_excerpt(); ?> 
         <a href="<?php the_permalink(); ?>" class="button-primary">En savoir plus</a> 
        </div> 
       </div> 
      <?php endwhile; ?> 
     <?php else: ?> 
      <h3>Page en cours de construction</h3> 
     <?php endif; ?> 
+0

使用自定義分類不想把帖子出來的IM –

+0

您可以更改您的文件taxonomy.php的名稱爲taxonomy- {name} .php。那可行 :) – Deveoo