在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函数:translate_nooped_plural 翻译并注册字符串WordPress函数:translate_nooped_plural 翻译并注册字符串
-
WordPress函数:number_format_i18n 数字国际化WordPress函数:number_format_i18n 数字国际化
-
WordPress函数:date_i18n 日期国际化WordPress函数:date_i18n 日期国际化
-
WordPress函数:esc_html_e 转义翻译的字符串并显示WordPress函数:esc_html_e 转义翻译的字符串并显示
-
WordPress函数:esc_attr_e 属性转义、翻译、显示WordPress函数:esc_attr_e 属性转义、翻译、显示
-
WordPress函数:esc_attr_x 带上下文的转义属性,翻译显示WordPress函数:esc_attr_x 带上下文的转义属性,翻译显示
暂无评论,抢个沙发...