Php Wordpress';get_comments()只返回文本,不返回HTML
我正在使用Php Wordpress';get_comments()只返回文本,不返回HTML,php,wordpress,comments,wordpress-theming,Php,Wordpress,Comments,Wordpress Theming,我正在使用get_comments()检索自定义主题中特定wordpress帖子的评论。问题是输出中没有HTML 例如,当用户向注释添加URL时,在管理控制台中,它显示为链接,但使用get\u comments()它只返回文本 由于本页上没有过滤器或其他选项,所以我不太清楚是什么问题。之后我应该用javascript来管理吗 谢谢你们的帮助,伙计们 我猜您可以应用“内容”过滤器 <?php foreach (get_comments() as $comment): ?> &l
get_comments()
检索自定义主题中特定wordpress帖子的评论。问题是输出中没有HTML
例如,当用户向注释添加URL时,在管理控制台中,它显示为链接,但使用get\u comments()
它只返回文本
由于本页上没有过滤器或其他选项,所以我不太清楚是什么问题。之后我应该用javascript来管理吗
谢谢你们的帮助,伙计们 我猜您可以应用“内容”过滤器
<?php foreach (get_comments() as $comment): ?>
<div class="comment">
<?=apply_filters('the_content', $comment->comment_content) ?>
</div>
<?php endforeach; ?>
我建议查看现有主题的
comments.php
模板文件,根据您的目的对其进行修改,然后通过comments\u template()
调用它
基于Zurb的基础框架的主题,使用<代码> WpListLyMax注释< /C> >:
<ol class="commentlist">
<?php wp_list_comments(); ?>
</ol>
看看这是否会给你一个更格式化的输出。你可以使用它,它会显示用户名、日期、化身和所有的p标签
<div class="comments">
<?php $comments_args = array(
// change the title of send button
'label_submit'=>'Send',
// change the title of the reply section
'title_reply'=>'Write a new comment',
// remove "Text or HTML to be displayed after the set of comment fields"
'comment_notes_after' => '',
// redefine your own textarea (the comment body)
'comment_field' => '<p class="comment-form-comment"><textarea id="comment" name="comment" aria-required="true" placeholder="Type your comment"></textarea></p>',
);
comment_form($comments_args); ?>
</div>
<div class="comments-form">
<?php
$user_id = get_current_user_id();
$user_specific_comments = get_comments(
array(
'post_id' => YOUR_POST_ID,
)
);
wp_list_comments(
array(
'per_page' => 10,
),
$user_specific_comments
);
?>
</div>
它确实添加了,但没有链接。:-/。好主意!