0

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)) {
                } } ?>
0

Following Mark Kaplun advice, I fixed my problem. Just wish there was a way to like a comment.

<?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 **strip_tags($content[$i])** . '</p>';
                    if ($i == ($paragraphAfter-1)) {
                } } ?>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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