Skip to main content
4 of 4
fix code

Strip HTML tags on custom code from the_content

I"m making a custom RSS feed and need a way to strip HTML tags from a custom code that grabs the first paragraph from a post.

This is what I'm using:

<?php
                    $paragraphAfter = 1; // shows image after paragraph 1
                    $paragraphsShow = 1; // shows first two paragraphs
                    $content = apply_filters('the_content', get_the_content());
                    $content = explode("</p>", $content);
                    $max = (count($content) < $paragraphsShow) ? count($content) : $paragraphsShow;
                    for ($i = 0; $i < $max; $i++) {
                        echo $content[$i] . "</p>";
                    if ($i == ($paragraphAfter-1)) {
                } } ?>