I went through your answer in post Issue with enabling formatting in excerpts in Wordpress. It works fine and closes tags so that a tag does not spill over to other posts. But I need to disable images from showing in the excerpts. How do I do that?

1 Answer 1


Use strip_tags() to strip all tags.
Pass tags you want to allow as second argument.
For you reference https://www.php.net/strip_tags

  • The problem isn't the stripping of tags as I have found many scripts that can do that. Most of them fail to close tags so if a post is truncated at bold or italic text, the following posts on the page also become bold or italic. The codes in the link in my above post are of two types. One that allows formatting but fails to close tags resulting in tag spill over. Another one that closes tags but fails to allow me to choose which tags I want to allow and which to remove. Jan 16, 2014 at 10:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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