Get First Link of a Post
If you want to get the first link of a post, you can use the snippet below:
function snippet_get_link_url() {
$content = get_the_content();
$has_url = get_url_in_content( $content );
return ( $has_url ) ? $has_url : apply_filters( 'the_permalink', get_permalink() );
}