wp_robots_noindex

函式
wp_robots_noindex ( $robots )
引數
  • (array) $robots Associative array of robots directives.
    Required:
返回值
  • (array) Filtered robots directives.
相關
  • wp_robots_no_robots()
定義位置
相關方法
wp_robots_noindex_embedswp_robots_noindex_searchwp_robotswp_robots_no_robotswp_create_nonce
引入
5.7.0
棄用
-

wp_robots_noindex: 這是一個WordPress的過濾鉤子,用來控制單個頁面的元標籤中的noindex設定。它用於控制搜尋引擎是否應該索引單個頁面。

如果網站配置需要,在robots元標籤中新增`noindex`。

如果一個部落格被標記為不公開,那麼noindex將被輸出,告訴網路機器人不要索引該頁面內容。把它新增到{@see ‘wp_robots’}過濾器中。

典型的用法是作為{@see ‘wp_robots’}的回撥。

add_filter( ‘wp_robots’, ‘wp_robots_noindex’) 。

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
function wp_robots_noindex( array $robots ) {
if ( ! get_option( 'blog_public' ) ) {
return wp_robots_no_robots( $robots );
}
return $robots;
}
function wp_robots_noindex( array $robots ) { if ( ! get_option( 'blog_public' ) ) { return wp_robots_no_robots( $robots ); } return $robots; }
function wp_robots_noindex( array $robots ) {
	if ( ! get_option( 'blog_public' ) ) {
		return wp_robots_no_robots( $robots );
	}

	return $robots;
}

常見問題

FAQs
檢視更多 >