Support » Fixing WordPress » "Post excerpt" actually showing parent page content

  • Hey everybody, Ive made this function with accompanying shortcode to display in page. The Title, and permalink are called correctly, however the ‘post_excerpt’ is actually displaying the content of the page this shortcode appears on, not the content of the post I pulled the title and link from.

    ‘Homepage’ uses [cch_single_post]
    [cch_single_post] displays recent post title
    when ‘post_excerpt’ is called, the content for ‘Homepage’ is rendered

    function cch_single_post() {
    	$args = array( 'numberposts' => '1' );
    	$recent_posts = wp_get_recent_posts( $args );
    	foreach( $recent_posts as $recent ){
    		$outPost = '<div class="cch_custom_post">';
    		$outPost .= '<h3><a href="' . get_permalink($recent["ID"]) . '" title="Look '.esc_attr($recent["post_title"]).'" >' .   $recent["post_title"].'</a> </h3><br/> ';
    		$outPost .= '<p>';
    		$outPost .= apply_filters( 'get_the_excerpt', $recent['post_excerpt'] ); //except now its just repeating all the content from the home page, post inception!
    		$outPost .= '</p>';
    		$outPost .= '</div>';
    	return $outPost;
  • The topic ‘"Post excerpt" actually showing parent page content’ is closed to new replies.