WordPress根据附件页面地址判断是否为本地附件:is_local_attachment

文 / @WordPress主题

WordPress函数is_local_attachment根据附件页面URL判断该附件是否为本地附件,注意这里的URL是附件页面地址,而非附件文件URL。

is_local_attachment( string $url )

函数参数

$url

字符串

附件页面的URL地址

函数使用示例

$url = 'https://www.tiezhushuo.com/3399.html/theme-tiezhushuo';
if(is_local_attachment($url)) {
	//本地附件
} else {
	//远程附件
}

扩展阅读

is_local_attachment()函数位于:wp-includes/post.php

相关函数:

  • is_attachment()
  • home_url()
  • get_post()
  • url_to_postid()
添加UTHEME为好友
扫码添加UTHEME微信为好友
· 分享WordPress相关技术文章,主题上新与优惠动态早知道。
· 微信端最大WordPress社群,限时免费入群。