Skip to main content
fix code
Source Link

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:

if(<?php
 ! $post->post_excerpt ) { 
                $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 ) ) {} 
                } } ?>

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:

if( ! $post->post_excerpt ) { 
   $paragraphAfter = 1; 
  $paragraphsShow = 1; 
  $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 ) ) {} 
  }

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)) {
                } } ?>
aligned the code little bit to make it readable
Source Link
Nicolai Grossherr
  • 18.9k
  • 8
  • 64
  • 109

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 if(!$post->post_excerpt) { $paragraphAfter = 1; $paragraphsShow = 1; $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)) {} } ?>

if( ! $post->post_excerpt ) { 
  $paragraphAfter = 1; 
  $paragraphsShow = 1; 
  $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 ) ) {} 
  }

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 if(!$post->post_excerpt) { $paragraphAfter = 1; $paragraphsShow = 1; $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)) {} } ?>

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:

if( ! $post->post_excerpt ) { 
  $paragraphAfter = 1; 
  $paragraphsShow = 1; 
  $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 ) ) {} 
  }

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 if(!$post->post_excerpt) { ?><?php $paragraphAfter = 1; $paragraphsShow = 1; $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)) {} } ?>

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 if(!$post->post_excerpt) { ?><?php $paragraphAfter = 1; $paragraphsShow = 1; $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)) {} } ?>

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 if(!$post->post_excerpt) { $paragraphAfter = 1; $paragraphsShow = 1; $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)) {} } ?>

Source Link
Loading