have_posts

函式
have_posts ( No parameters )
返回值
  • (bool) True if posts are available, false if end of the loop.
定義位置
相關方法
the_postget_postshave_commentsnext_postsget_post
引入
1.5.0
棄用
-

have_posts – 這是一個WordPress函式,用於檢查當前查詢是否有任何文章可以顯示。文章是WordPress網站上的主要內容型別,它們可以通過查詢以各種方式組織和過濾。have_posts函式通常用於一個迴圈,在查詢結果集中迭代每個文章。

確定當前的WordPress查詢是否有文章可供迴圈使用。

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
function have_posts() {
global $wp_query;
if ( ! isset( $wp_query ) ) {
return false;
}
return $wp_query->have_posts();
}
function have_posts() { global $wp_query; if ( ! isset( $wp_query ) ) { return false; } return $wp_query->have_posts(); }
function have_posts() {
	global $wp_query;

	if ( ! isset( $wp_query ) ) {
		return false;
	}

	return $wp_query->have_posts();
}

常見問題

FAQs
檢視更多 >