WordPress.org

Ready to get started?Download WordPress

Forums

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

  1. Gabe462
    Member
    Posted 1 year 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. alchymyth
    The Sweeper & Moderator
    Posted 1 year 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