_draft_or_post_title

函数
_draft_or_post_title ( $post = 0 )
参数
  • (int|WP_Post) $post Optional. Post ID or WP_Post object. Default is global $post.
    Required:
返回值
  • (string) The post title if set.
定义位置
相关方法
wp_latest_comments_draft_or_post_titleregister_block_core_post_titlerender_block_core_post_title_get_last_post_timeget_post_time
引入
2.7.0
弃用
-

_draft_or_post_title: 这个函数用来检索一个文章或草稿的标题。它也可以用来为一个新的文章或草稿生成一个默认的标题。

获取文章的标题。

获取文章的标题,如果它是空白的,那么将返回一个默认的字符串。

function _draft_or_post_title( $post = 0 ) {
	$title = get_the_title( $post );
	if ( empty( $title ) ) {
		$title = __( '(no title)' );
	}
	return esc_html( $title );
}

常见问题

FAQs
查看更多 >
闪电侠

(工作日 10:00 - 18:30 为您服务)

2025-12-05 18:32:58

您好,无论是售前、售后、意见建议……均可通过联系工单与我们取得联系。

您也可选择聊天工具与我们即时沟通或点击查看:

您的工单我们已经收到,我们将会尽快跟您联系!
取消
选择聊天工具: