You can get the post ID from the excerpt, but as far as I can tell, WP_Query
doesn’t support this (very well), so you need to write a custom WPDB query.
function get_post_id_by_excerpt($excerpt) {
global $wpdb;
$result = $wpdb->get_row(
$wpdb->prepare("SELECT ID FROM {$wpdb->prefix}posts WHERE post_excerpt LIKE %s", $excerpt)
);
return $result;
}
For this to work, you need to pass the exact excerpt (incl. HTML) to the function