• I’ve searched many threads in the forum and found a solution to outputting the excerpts of post without being inside the loop… Only the solution I found doesn’t work… What is going on?

    function wptuts_recentposts($atts, $content = null){
    global $post;
    $list_start = '<ul class="recent_posts">';
    $list_end = '</ul>';
    $output = '';
    $recent_posts = wp_get_recent_posts();
    foreach( $recent_posts as $current_post ){
    get_post($current_post["ID"]);
    $excerpt = $postid->post_excerpt;
    		$output .= '
    <li>
    	<div class="recent_wrapper">
    		<h4><a href=' . get_permalink($current_post["ID"]) .  '>' .   $current_post["post_title"].'</a></h4>'. get_the_post_thumbnail($current_post["ID"], array(75,75)) . $excerpt . '
    	</div>
    </li>';
    	}
    return $list_start . $output . $list_end;
    
    }
    add_shortcode('recent_posts', 'wptuts_recentposts');

Viewing 1 replies (of 1 total)
  • Thread Starter Rubyfire

    (@rubyfire)

    Got It… for some reasons I never tried
    (This works)
    $current_post["post_excerpt"]

    where I have

    (This don’t)
    $current_post->post_excerpt

Viewing 1 replies (of 1 total)
  • The topic ‘Cannot get the excerpt to show outside the loop… code provided.’ is closed to new replies.