_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: 這個函式用來檢索一個文章或草稿的標題。它也可以用來為一個新的文章或草稿生成一個預設的標題。

獲取文章的標題。

獲取文章的標題,如果它是空白的,那麼將返回一個預設的字串。

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
function _draft_or_post_title( $post = 0 ) {
$title = get_the_title( $post );
if ( empty( $title ) ) {
$title = __( '(no title)' );
}
return esc_html( $title );
}
function _draft_or_post_title( $post = 0 ) { $title = get_the_title( $post ); if ( empty( $title ) ) { $title = __( '(no title)' ); } return esc_html( $title ); }
function _draft_or_post_title( $post = 0 ) {
	$title = get_the_title( $post );
	if ( empty( $title ) ) {
		$title = __( '(no title)' );
	}
	return esc_html( $title );
}

常見問題

FAQs
檢視更多 >