GET the excerpt by ID

Hi @Robin I. Knight:

I view get_the_excerpt() as a function with legacy design. As WordPress usage has grown there are many newer use-cases where it doesn’t fit but where the newer functions for getting different data do. One example is the now frequent use of an $args array of function options.

But it’s easy to fix for your needs. Here’s an alternative function you can use which you can put anywhere in your theme’s functions.php file:

function robins_get_the_excerpt($post_id) {
  global $post;  
  $save_post = $post;
  $post = get_post($post_id);
  $output = get_the_excerpt();
  $post = $save_post;
  return $output;
}

I’ve not tested it but am pretty sure I got it right. If this doesn’t meet your needs please elaborate and maybe I can make other suggestions.

Leave a Comment