wp_robots_noindex_search

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

wp_robots_noindex_search: 這是一個WordPress的過濾鉤子,用於控制搜尋結果頁面的不索引設定。它用於控制搜尋引擎是否應該索引搜尋結果頁面。

如果正在進行搜尋,將`noindex`新增到robots元標籤中。
如果正在進行搜尋,那麼noindex將被輸出,告訴網路機器人不要對頁面內容進行索引。將其新增到{@see ‘wp_robots’}過濾器中。

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

add_filter( ‘wp_robots’, ‘wp_robots_noindex_search’) ;

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
function wp_robots_noindex_search( array $robots ) {
if ( is_search() ) {
return wp_robots_no_robots( $robots );
}
return $robots;
}
function wp_robots_noindex_search( array $robots ) { if ( is_search() ) { return wp_robots_no_robots( $robots ); } return $robots; }
function wp_robots_noindex_search( array $robots ) {
	if ( is_search() ) {
		return wp_robots_no_robots( $robots );
	}

	return $robots;
}

常見問題

FAQs
檢視更多 >