首页 文章

Wordpress的'get_comments()只返回文本而不返回HTML

提问于
浏览
0

我正在使用 get_comments() 来检索我的自定义主题中特定wordpress帖子的评论 . 问题是输出中没有HTML .

例如,当用户向注释添加URL时,在管理控制台中它显示为链接但使用 get_comments() 它只返回文本 .

由于此页面上没有涵盖此内容的过滤器或其他选项:http://codex.wordpress.org/Function_Reference/get_comments我不太清楚是什么问题 . 我以后应该用javascript管理它吗?

谢谢你的帮助!

2 回答

  • 0

    我猜你可以应用'the_content'过滤器;

    <?php foreach (get_comments() as $comment): ?>
        <div class="comment">
            <?=apply_filters('the_content', $comment->comment_content) ?>
        </div>
    <?php endforeach; ?>
    
  • 1

    我是'd recommend taking a look at an existing theme' s comments.php 模板文件,修改它以适合您的目的,然后通过 comments_template() 调用它 .

    基于ZURB基础框架的主题for example使用 wp_list_comments

    <ol class="commentlist">
        <?php wp_list_comments(); ?>
    </ol>
    

    看看是否能为您提供更加格式化的输出 .

相关问题