Do you want a specific excerpt, the most recent one, or a random one…need a little more clarification please.
Given a specific post id, what’s the best way to get it’s excerpt into a variable? Querypost?
$excerpt = get_the_excerpt();
It has to be within the loop. If you want a specific post excerpt outside the loop:
global $post;
get_post(‘7’);
$excerpt = $postid->post_excerpt;
That’ll return the excerpt for the post with an ID of “7”.
Awesome and great detail doodlebee. Thanks!
Use get_the_excerpt() function.
EXAMPLE :<?php
$myExcerpt = get_the_excerpt();
if ($myExcerpt != ”) {
// Some string manipulation performed
}
echo $myExcerpt; // Outputs the processed value to the page
?>
for more check http://codex.wordpress.org/Function_Reference/get_the_excerpt