wp_latest_comments_draft_or_post_title

函式
wp_latest_comments_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; "(no title)" if no title is set.
定義位置
相關方法
_draft_or_post_title_close_comments_for_old_post_close_comments_for_old_postscomment_form_titlewp_cache_set_comments_last_changed
引入
3.3.0
棄用
-

wp_latest_comments_draft_or_post_title: 這個函式返回最新評論的草稿或文章的標題。

獲取文章的標題。

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

從`wp-admin/includes/template.php`複製,但我們不能包括該檔案,因為:

1. 它會導致測試夾具生成的錯誤和奇怪的Docker 255錯誤程式碼。
2. 它在管理中;理想情況下,我們不應該*從管理中為一個塊的輸出包括檔案。這也是一個非常小/簡單的功能,所以重複它並不可怕。

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

常見問題

FAQs
檢視更多 >