is_home

函式
is_home ( No parameters )
返回值
  • (bool) Whether the query is for the blog homepage.
相關
  • is_front_page()
定義位置
相關方法
is_timelist_metais_authordisplay_themeis_attachment
引入
1.5.0
棄用
-

is_home: 如果當前頁面是網站的部落格首頁,該函式返回true。部落格主頁是顯示網站最新的部落格文章的頁面。

確定查詢是否為部落格主頁。

部落格主頁是顯示網站基於時間的部落格內容的頁面。

is_home()取決於網站的””首頁顯示”” 閱讀設定’show_on_front’和’page_for_posts’。

如果一個靜態頁面被設定為網站的首頁,這個函式將只在你設定為””文章頁面””的頁面上返回真。

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

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
function is_home() {
global $wp_query;
if ( ! isset( $wp_query ) ) {
_doing_it_wrong( __FUNCTION__, __( 'Conditional query tags do not work before the query is run. Before then, they always return false.' ), '3.1.0' );
return false;
}
return $wp_query->is_home();
}
function is_home() { global $wp_query; if ( ! isset( $wp_query ) ) { _doing_it_wrong( __FUNCTION__, __( 'Conditional query tags do not work before the query is run. Before then, they always return false.' ), '3.1.0' ); return false; } return $wp_query->is_home(); }
function is_home() {
	global $wp_query;

	if ( ! isset( $wp_query ) ) {
		_doing_it_wrong( __FUNCTION__, __( 'Conditional query tags do not work before the query is run. Before then, they always return false.' ), '3.1.0' );
		return false;
	}

	return $wp_query->is_home();
}

常見問題

FAQs
檢視更多 >