is_front_page

函式
is_front_page ( No parameters )
返回值
  • (bool) Whether the query is for the front page of the site.
定義位置
相關方法
is_pageis_plugin_pageis_pagedis_countableis_tag
引入
2.5.0
棄用
-

is_front_page: 如果當前頁面是網站的首頁,該函式返回true。前臺頁面是網站的主頁面,當有人訪問網站時就會顯示。

確定查詢是否為網站的首頁。

這是針對在你的網站的主URL上顯示的內容。

取決於網站的””首頁顯示”” 閱讀設定’show_on_front’和’page_on_front’。

如果你為網站的首頁設定了一個靜態頁面,在檢視該頁面時,這個函式將返回true。

否則與@see is_home()相同。

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

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
function is_front_page() {
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_front_page();
}
function is_front_page() { 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_front_page(); }
function is_front_page() {
	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_front_page();
}

常見問題

FAQs
檢視更多 >