WordPress函数is_local_attachment根据附件页面URL判断该附件是否为本地附件,注意这里的URL是附件页面地址,而非附件文件URL。
is_local_attachment( string $url )
函数参数
$url
字符串
附件页面的URL地址
函数使用示例
$url = 'https://www.beizigen.com/post/wordpress-is-concise-and-refreshing-blog-theme-beizigen.html/theme-beizigen'; if(is_local_attachment($url)) { //本地附件 } else { //远程附件 }
扩展阅读
is_local_attachment()函数位于:wp-includes/post.php
相关函数:
- is_attachment()
- home_url()
- get_post()
- url_to_postid()