have_comments

函式
have_comments ( No parameters )
返回值
  • (bool) True if comments are available, false if no more comments.
定義位置
相關方法
the_commentget_commentscheck_commentget_commentseparate_comments
引入
2.2.0
棄用
-

have_comments – 這是一個WordPress函式,用來檢查當前的文章或頁面是否有任何評論可以顯示。評論是訪問者在網站上留下反饋或提出問題的一種方式,它們可以由網站管理員進行調節和管理。如果有評論,函式have_comments返回true,如果沒有則返回false。

確定當前的WordPress查詢是否有評論可以迴圈使用。

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

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

	return $wp_query->have_comments();
}

常見問題

FAQs
檢視更多 >