我想确定一篇文章有多少张图片,特别是如果只有一张的话。基本上,如果有多个图像我想显示我的幻灯片脚本,如果只有一个图像我想显示该图像,而不是加载幻灯片。
我在一篇类似的帖子上看到了这一点,这篇帖子确定是否附加了任何图像:
$attachments = get_children( array(\'post_parent\' => get_the_ID(), \'post_type\' => \'attachment\', \'post_mime_type\' => \'image\') );
if ( $attachments ) {
// do conditional stuff here
}
我是否可以使用类似的方法来确定是否只有一个图像?谢谢