get_url_in_content

函数
get_url_in_content ( $content )
参数
  • (string) $content A string which might contain a URL.
    Required:
返回值
  • (string|false) The found URL.
定义位置
相关方法
get_the_contentget_user_countget_link_to_editget_media_embedded_in_contentget_blog_count
引入
3.6.0
弃用
-

get_url_in_content: 这个函数检索出现在文章内容中的第一个URL。它接收一个文章ID作为参数,并以字符串形式返回URL。

从传来的内容中提取并返回第一个URL。

function get_url_in_content( $content ) {
	if ( empty( $content ) ) {
		return false;
	}

	if ( preg_match( '/<as[^>]*?href=(['"])(.+?)1/is', $content, $matches ) ) {
		return sanitize_url( $matches[2] );
	}

	return false;
}

常见问题

FAQs
查看更多 >
闪电侠

(工作日 10:00 - 18:30 为您服务)

2025-12-05 19:32:59

您好,无论是售前、售后、意见建议……均可通过联系工单与我们取得联系。

您也可选择聊天工具与我们即时沟通或点击查看:

您的工单我们已经收到,我们将会尽快跟您联系!
取消
选择聊天工具: