filtrod 5.7.0
wp_robots
Opis
Modyfikuje dyrektywy meta robots generowane przez WordPress.
Przykład użycia
add_filter( 'wp_robots', ... )php
add_filter( 'wp_robots', 'wpdocs_noindex_search' );
function wpdocs_noindex_search( $robots ) {
if ( is_search() ) {
$robots['noindex'] = true;
}
return $robots;
}
add_filter( 'wp_robots', 'wpdocs_noindex_search' );
function wpdocs_noindex_search( $robots ) {
if ( is_search() ) {
$robots['noindex'] = true;
}
return $robots;
}The meta tag will only be included as necessary.
Parametry
| Parametr | Typ | Opis |
|---|---|---|
$robots | array | Associative array of directives. Every key must be the name of the directive, and the corresponding value must either be a string to provide as value for the directive or a boolean <code>true</code> if it is a boolean directive, i.e. without a value. |
Wywołanie
Rejestracja callbackaphp
// rejestracja funkcji zwrotnej
add_filter( 'wp_robots', 'twoja_funkcja' );
function twoja_funkcja($param_1) {
// Twój kod
}
// rejestracja funkcji zwrotnej
add_filter( 'wp_robots', 'twoja_funkcja' );
function twoja_funkcja($param_1) {
// Twój kod
}Popularne w tej kategorii