admin管理员组文章数量:1336660
These are actually input fields. paragraph is the textarea field. i query the contents from database and try to show them in this textarea field. But the textarea field is showing me unwanted comments and tags. When I echo them outtside the textarea field, it is fine.
My code....
<?php while($userNotes->have_posts()): $userNotes->the_post(); ?>
<li>
<input value="<?php echo esc_attr(get_the_title()); ?>" class="note-title-field">
<span class="edit-note"><i class="fa fa-pencil" aria-hidden="true"></i> Edit</span>
<span class="delete-note"><i class="fa fa-trash-o" aria-hidden="true"></i> Delete</span>
<textarea class="note-body-field"><?php echo esc_attr(get_the_content()); ?></textarea>
</li>
<?php endwhile; ?>
These are actually input fields. paragraph is the textarea field. i query the contents from database and try to show them in this textarea field. But the textarea field is showing me unwanted comments and tags. When I echo them outtside the textarea field, it is fine.
My code....
<?php while($userNotes->have_posts()): $userNotes->the_post(); ?>
<li>
<input value="<?php echo esc_attr(get_the_title()); ?>" class="note-title-field">
<span class="edit-note"><i class="fa fa-pencil" aria-hidden="true"></i> Edit</span>
<span class="delete-note"><i class="fa fa-trash-o" aria-hidden="true"></i> Delete</span>
<textarea class="note-body-field"><?php echo esc_attr(get_the_content()); ?></textarea>
</li>
<?php endwhile; ?>
Share
Improve this question
edited May 7, 2019 at 11:28
tru.d
1861 gold badge1 silver badge17 bronze badges
asked May 7, 2019 at 5:22
Bikash GurungBikash Gurung
213 bronze badges
3
|
2 Answers
Reset to default -1Can you please try this php function html_entity_decode(get_the_content());
. I have used this function on php to remove html tags, you can try this.
You can try this:
<textarea class="note-body-field"><?php echo sanitize_text_field(get_the_content()); ?>
</textarea>
I'm also a beginner, but found this works in the frontend. And it seems to be intended for similar use cases - https://developer.wordpress/reference/functions/sanitize_text_field/
本文标签: How to remove these comments and html tags from the content
版权声明:本文标题:How to remove these comments and html tags from the content? 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742420643a2471586.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
esc_attr()
applied to the post content. If you strip tags from content, you lost text formatting ability from editor (bold, italic, paragraph, etc.). – nmr Commented May 7, 2019 at 6:19