Loop that strips unwanted html

/ Published in: PHP
Save to your folder(s)

strip html on loop

Copy this code and paste it in your HTML
  1. <?php if (have_posts()) : while (have_posts()) : the_post();?>
  2. <?php ob_start();
  3. the_content(''.__('Read more <span class="meta-nav">&raquo;</span>', 'sandbox').'');
  4. $old_content = ob_get_clean();
  5. $new_content = strip_tags($old_content, '<hr><div><p><a><em><b><input><form><img><textarea><li><ol><ul><table><tr><td><th><i><b><h1><h2><h3><h4><h5><h6>');
  6. echo $new_content; ?>
  7. <?php endwhile; endif; ?>
  8. <?php edit_post_link('Edit this entry.', '<p>', '</p>'); ?>

Report this snippet


RSS Icon Subscribe to comments

You need to login to post a comment.