在WordPress中,wp_attachment_is_image 用来判断文章是否是附件。可以接受文章ID或WP_Post类型对象。
函数源码:
function wp_attachment_is_image( $post = null ) {
return wp_attachment_is( 'image', $post );
}
可以看到源码直接调用了 wp_attachment_is,是一个语法糖函数。
使用举例:
$id = 37;
if ( wp_attachment_is_image( $id ) ) {
printf( 'Post %d is an image!', $id );
} else {
printf( 'Post %d is not an image.', $id );
}
-
WordPress函数:国际化 __() 获取翻译的字符串WordPress函数:国际化 __() 获取翻译的字符串
-
WordPress函数:国际化 _x() 获取具有gettext上下文的翻译字符串。WordPress函数:国际化 _x() 获取具有gettext上下文的翻译字符串。
-
WordPress函数:国际化 _ex 展示带上下文的翻译字符串WordPress函数:国际化 _ex 展示带上下文的翻译字符串
-
WordPress函数:国际化 _nx 翻译字符串,_n + _xWordPress函数:国际化 _nx 翻译字符串,_n + _x
-
WordPress函数:国际化 _nx_noop 在 pot 中注册字符串WordPress函数:国际化 _nx_noop 在 pot 中注册字符串
-
WordPress函数:translate_nooped_plural 翻译并注册字符串WordPress函数:translate_nooped_plural 翻译并注册字符串
暂无评论,抢个沙发...