How to Strip HTML Tag In the_content Function

Share This Post

Share on facebook
Share on twitter
Share on linkedin
Share on whatsapp
Fast Hosting as low as $2 per month

Last Updated: October 6, 2013 | Reading Time: < 1 minute

Awfull formatting your client use within the editor -most of them use copy and paste from word processor- can break your layout.

Below is the code to strip out unwanted tag. Just replace the_content.

global $more; $more = 0;
the_content(”.__(”, ‘sg’).”);
$old_content = ob_get_clean();
$new_content = strip_tags($old_content, ‘<p><a><br /><img>’); //list tag to be allowed
echo $new_content;[/php]

At least it works for me 🙂

Any idea? Fill the comment below

This site uses Akismet to reduce spam. Learn how your comment data is processed.

More To Explore