WordPress.org

Support

Support » Themes and Templates » Strip tags but allow some

Strip tags but allow some

  • How do I remove all tags but allow some?
    I want to remove all tags from the_content but allow the p and a tag. I have tried this inside a div;

    <?php echo strip_tags(get_the_content()),'<p><a>';?>
    That strips every tag. What is wrong?

    Thanks!

Viewing 2 replies - 1 through 2 (of 2 total)
  • Sorry, the code is wrong. Once again:

    <?php echo strip_tags(get_the_content(),'<p><a>');?>

    davidjoshua
    Member

    @davidjoshua

    Abit of a late reply, but you haven’t separated the tags with a comma.

    strip_tags(get_the_content(), '<p>, <ul>, <li>, <a>')

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Strip tags but allow some’ is closed to new replies.