WordPress.org

Ready to get started?Download WordPress

Forums

Strip tags but allow some (3 posts)

  1. Indent
    Member
    Posted 9 months ago #

    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!

  2. Indent
    Member
    Posted 9 months ago #

    Sorry, the code is wrong. Once again:

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

  3. davidjoshua
    Member
    Posted 7 months ago #

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

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

Reply

You must log in to post.

About this Topic