2010-07-21 66 views
0

我在WordPress內容之外的靜態HTML頁面上顯示WordPress內容。它工作得非常好,我只需要一個元素來完成設置。WordPress - 如何顯示來自條目的評論總數?

我使用這個代碼:

<?php while (have_posts()): the_post(); ?> 
    <h5><?php the_title(); ?></h5> 
    <p class="blog-info"><?php the_time('m'); ?>.<?php the_time('j'); ?>.<?php the_time('y'); ?> | <a class="comment-ref">13 Comments</a></p> 
<?php endwhile; ?> 

的最後一部分,我需要在這裏你可以看到與該項目相關的意見總數的鏈接部分。這樣的事情:

<a class="comment-ref">13 Comments</a> 

我對WordPress不是很熟悉,所以我可以使用一些幫助獲取最後一點代碼。

謝謝!

回答

4

你需要像這樣...

<a class="comments-ref" href="<?php comments_link(); ?>"> 
    <?php comments_number('0', '1', '%'); ?> Comments 
</a> 
+0

是的,comments_number是要走的路。 http://codex.wordpress.org/Function_Reference/comments_number – 2010-07-21 13:43:47

+1

優秀。完美工作!謝謝。 – fmz 2010-07-21 13:46:16

1

這裏是an article,可能是你的興趣。 :)

e:幹得好,JAG2007。

+0

是的,這也是一件好事情通讀。我發佈的僅僅是如何提出評論的一個例子。實際上有幾種方法,包括如果評論的值爲0,則設置爲打印「尚未評論」或「先評論」。 – 2010-07-21 20:32:12