Skip to content
ID ) ) {
$image_url = get_the_post_thumbnail_url( $post->ID, 'full' );
}
// 2. Fallback to first inline image
else {
preg_match_all( '//i', $post->post_content, $matches );
if ( ! empty( $matches[1][0] ) ) {
$image_url = $matches[1][0];
}
}
if ( $image_url ) {
return '
';
}
return '';
}
add_shortcode( 'first_post_image', 'get_first_post_image_shortcode' );
?>