has_excerpt

函式
has_excerpt ( $post = 0 )
引數
  • (int|WP_Post) $post Optional. Post ID or WP_Post object. Default is global $post.
    Required:
返回值
  • (bool) True if the post has a custom excerpt, false otherwise.
定義位置
相關方法
the_excerptget_the_excerptwp_html_excerptthe_excerpt_rssthe_excerpt_embed
引入
2.3.0
棄用
-

has_excerpt – 這是一個WordPress函式,用於檢查當前文章是否有定義的摘錄。摘錄是一個文章或頁面內容的簡短摘要或描述,顯示在檔案頁或搜尋結果中。has_excerpt函式接受一個引數,即文章的ID或物件,如果該文章有定義的摘錄,則返回true。

確定該文章是否有一個自定義的摘錄。

關於這個和類似的主題功能的更多資訊,請檢視《主題開發者手冊》中的{@link Conditional Tags}文章。

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
function has_excerpt( $post = 0 ) {
$post = get_post( $post );
return ( ! empty( $post->post_excerpt ) );
}
function has_excerpt( $post = 0 ) { $post = get_post( $post ); return ( ! empty( $post->post_excerpt ) ); }
function has_excerpt( $post = 0 ) {
	$post = get_post( $post );
	return ( ! empty( $post->post_excerpt ) );
}

常見問題

FAQs
檢視更多 >