2014-02-25 64 views
0

我有一個循環的頁面,列出所有的子類別的類別描述,發佈數量和最後發佈的發佈日期。Add WordPress的評論計數

Child category name      post count comment count pubdate 
Child category description     5   xxx    

• last published post in cat 
• second last published post in cat 

我用這塊PHP完成了這件事。

<?php $categories = get_categories('child_of=225'); 

foreach ($categories as $category) { 
    //Display the sub category information using $category values like $category->cat_name 
    echo '<div class="row clearfix">'; 
    echo '<div class="col1"><div class="inner"><h2>'.$category->name.'</h2>'; 
    echo '<p>'.$category->description.'</p>'; 
    echo '<p class="recent"><strong>Meest recent:</strong></p>'; 
    echo '<ul class="recentlist">'; 

    foreach (get_posts('posts_per_page=2&cat='.$category->term_id) as $post) { 
     setup_postdata($post); 
     $my_date = mysql2date('D j M Y', $post->post_date); 

     $commentcount = ; 

    echo '<li><a href="'.get_permalink($post->ID).'">'.get_the_title().'</a></li>'; 
} 

echo '</ul>'; 

echo '</div></div>'; //end .col1 .inner 

echo '<div class="col2">'.$category->count.'</div>'; 

echo '<div class="col3">'.$commentcount.'</div>'; 

echo '<div class="col4">'.$my_date.'</div></div>'; 

} ?> 

我似乎無法得到評論計數工作。我知道語法需要工作...即時通訊工作。

任何人都可以指向正確的方向嗎?

乾杯, 保羅

回答

0
$commentcount = get_comments_number($post->ID); 

這應該獲取在該帖子的評論總數。