Mayccoll
1/7/2016 - 7:08 PM

Get first link in post

Get first link in post

<?php
function THEME_get_first_content_link ( $content = false, $echo = false ) {
  $string = $content;
  $re1='((?:http|https)(?::\\/{2}[\\w]+)(?:[\\/|\\.]?)(?:[^\\s"]*))';    # HTTP URL 1
  preg_match_all( $re1, $string, $match);
  return $match;
}
?>