参数
- $format
-
(string|string[]) (可选) 要检查的一种或多种格式。
默认值: array()
- $post
-
(WP_Post|int|null) (可选) 要检查的文章,默认为循环中的当前文章。
默认值: null
返回
(bool) 如果文章有给定的格式或任意格式(如果没有指定格式的话),则为true,否则为false。
说明
用法:
$format = has_post_format($format, $post_id);
源码
更新日志
版本 | 描述 |
---|---|
3.1.0 | 开始引入 |
使用示例
从Codex迁移的示例:
<?php /* * Do something if the post format is a gallery */ if ( has_post_format('gallery') ) { // Do something } ?>