Get link value only from the_content()

$post_link = get_the_permalink();
if ( preg_match('/<a (.+?)>/', get_the_content(), $match) ) {
    $link = array();
    foreach ( wp_kses_hair($match[1], array('http')) as $attr) {
        $link[$attr['name']] = $attr['value'];
    }
    $post_link = $link['href'];
}

http://wordpress.stackexchange.com/questions/13448/get-link-value-only-from-the-content

Processing your request, Please wait....

No Responses to “Get link value only from the_content()”

Comments (Your Comments)

Leave a Reply

You must be logged in to post a comment.