wp_robots_no_robots

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

wp_robots_no_robots: 這是一個WordPress的過濾鉤子,用來控制robots.txt檔案中的noindex設定。它是用來控制搜尋引擎是否應該索引網站的。

在robots元標籤中新增`noindex’。

這條指令告訴網路機器人不要對頁面內容進行索引。

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

add_filter( ‘wp_robots’, ‘wp_robots_no_robots’ ) ;

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
function wp_robots_no_robots( array $robots ) {
$robots['noindex'] = true;
if ( get_option( 'blog_public' ) ) {
$robots['follow'] = true;
} else {
$robots['nofollow'] = true;
}
return $robots;
}
function wp_robots_no_robots( array $robots ) { $robots['noindex'] = true; if ( get_option( 'blog_public' ) ) { $robots['follow'] = true; } else { $robots['nofollow'] = true; } return $robots; }
function wp_robots_no_robots( array $robots ) {
	$robots['noindex'] = true;

	if ( get_option( 'blog_public' ) ) {
		$robots['follow'] = true;
	} else {
		$robots['nofollow'] = true;
	}

	return $robots;
}

常見問題

FAQs
檢視更多 >