发表评论依靠我的网站链接到帖子链接或评论区域

时间:2014-06-07 19:37:35

标签: php wordpress permalinks

我最近通过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>

1 个答案:

答案 0 :(得分: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>
相关问题