Forums

Cannot get the excerpt to show outside the loop... code provided. (2 posts)

  1. Rubyfire
    Member
    Posted 8 months ago #

    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');
  2. Rubyfire
    Member
    Posted 8 months ago #

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

    where I have

    (This don't)
    $current_post->post_excerpt

Reply

You must log in to post.

About this Topic