Instead of using get_posts
, which you would use if you wanted to retrieve multiple posts in a loop, you should use get_post
, which only retrieves one post by an ID. There is also a built-in excerpt so you might want to go with retrieving post_excerpt
.
function get_the_excerpt_id($post_id) {
$find = get_post($post_id);
$excerpt = $find->post_excerpt;
$excerpt = strip_tags($excerpt);
$output = substr($excerpt, 0, 100);
return $output;
}