Title: Strip html codes from Posts
Last modified: August 19, 2016

---

# Strip html codes from Posts

 *  [sazuka](https://wordpress.org/support/users/sazuka/)
 * (@sazuka)
 * [15 years, 9 months ago](https://wordpress.org/support/topic/strip-html-codes-from-posts/)
 * I saw a solution i believe which i found from a different Theard on this forum.
 * Here are 2 codes but I dont know where to insert them on wordpress? which template?
 *     ```
       <?php
       ob_start();
        the_content(''.__('Read more <span class="meta-nav">&raquo;</span>', 'sandbox').'');
       $old_content = ob_get_clean();
       $new_content = strip_tags($old_content);
       echo $new_content;
       ?>
       ```
   
 * and
 * `$new_content = strip_tags($old_content, '<p><a><b><br /><input><form><img><textarea
   ><li><ol><ul><table>');`

Viewing 2 replies - 1 through 2 (of 2 total)

 *  [Michael](https://wordpress.org/support/users/alchymyth/)
 * (@alchymyth)
 * [15 years, 9 months ago](https://wordpress.org/support/topic/strip-html-codes-from-posts/#post-1636087)
 * where to put the code depends on where you want to show the content stripped 
   of html tags.
 * if you want to show it on the front page, the template is likely to be index.
   php; for single post view, it would be single.php.
 * what are you trying to achieve? could you post more details?
 *  Thread Starter [sazuka](https://wordpress.org/support/users/sazuka/)
 * (@sazuka)
 * [15 years, 9 months ago](https://wordpress.org/support/topic/strip-html-codes-from-posts/#post-1636110)
 * Actually because People are allowed to register on my wordpress and make guest
   posts and i want to stop them from adding some wierd html codes including iframe
   forms etc…
 * Is there no way to make it auto strip it inside the database with a plugin.. 
   I just wasnt able to find such a plugin yet..

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Strip html codes from Posts’ is closed to new replies.

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 2 replies
 * 2 participants
 * Last reply from: [sazuka](https://wordpress.org/support/users/sazuka/)
 * Last activity: [15 years, 9 months ago](https://wordpress.org/support/topic/strip-html-codes-from-posts/#post-1636110)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
