确定帖子是否有自定义摘录。
原型
has_excerpt( int|WP_Post $post )
描述
有关此功能和类似主题功能的更多信息,请查看Theme Developer Handbook中的Conditional Tags文章。
参数
$post
(int|WP_Post)
(Optional)
发布ID或WP_Post对象。默认为全球$ post。
返回值
(bool)
如果帖子有自定义摘录,则为True,否则为false。
源文件
路径:wp-includes/post-template.php
<?php
...
function has_excerpt( $post = 0 ) {
$post = get_post( $post );
return ( !empty( $post->post_excerpt ) );
}
...
?>
其他
英文文档:https://developer.wordpress.org/reference/functions/has_excerpt/