1

enter image description here

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; ?>
  • What can you see when you goto edit post? – Vishwa May 7 at 6:10
  • 2
    You see tags because of 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 May 7 at 6:19
  • even if i remove esc_attr(), it shows same... I used strip_tags() and it worked but text formatting is lost.. Is there any perfect solution for this? – Bikash Gurung May 7 at 9:29
-1

Can 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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.