get_the_excerpt() errors where get_the_content() works (2 posts)

  1. Gabe462
    Posted 3 years ago #

    I thought get_the_excerpt() would basically be a stripped/filtered get_the_content().

    But if I try to swap get_the_excerpt() for get_the_content(), the site crashes. Why doesn't this work?

    function add_to_content( $content ) {
    		$got_content = strip_tags( get_the_content() );
    		echo "<!-- content: $got_content -->";
    	return $content;
    add_filter( 'the_content', 'add_to_content');
  2. Michael
    Forum Moderator
    Posted 3 years ago #

    get_the_excerpt() uses wp_trim_excerpt() which in turn uses the filter 'the_content' - so you are basically creating something that calls itself again and again...

Topic Closed

This topic has been closed to new replies.

About this Topic