2014-06-07 58 views
1

我最近通過this tutorial更新了我的評論代碼。我用下面的代碼替換了默認的comments_popup_link。這對於顯示真實評論數量很有效(FB評論+ WP評論),但是,我無法找到一種方法來獲取評論數量文本以鏈接到帖子固定鏈接。有什麼建議?發表評論請在我的網站上鍊接到帖子鏈接或評論區域

<span class="comments-link"> 
<?php 
    $commentCount = full_comment_count(); 
    if ($commentCount == 0) { 
     echo '<post-date>- Leave a comment</post-date>'; 
    } 
    else if ($commentCount == 1) { 
     echo '<post-date>- One comment</post-date>'; 
    } 
    else { 
     echo '<post-date>- ' . $commentCount . ' comments</post-date>'; 
} 
?> 
</span> 

回答

0

我想,這樣你就可以鏈接到您的意見

<a href="<?php the_permalink(); ?>/#comments"> 

<span class="comments-link"> 
<?php 
    $commentCount = full_comment_count(); 
    if ($commentCount == 0) { 
     echo '<post-date>- Leave a comment</post-date>'; 
    } 
    else if ($commentCount == 1) { 
     echo '<post-date>- One comment</post-date>'; 
    } 
    else { 
     echo '<post-date>- ' . $commentCount . ' comments</post-date>'; 
} 
?> 
</span> 
</a> 
+0

如果沒有,更改第一行:'的 /。評論鏈接「>」 –

+0

沒問題@ user3696987。很高興幫助你:) 考慮將此答案標記爲正確。問候 –