Notice: There is no legacy documentation available for this item, so you are seeing the current documentation.
Purpose
This filter can be used to filter the robots meta tag attributes.
Arguments (1)
- $attributes (array) – The robots meta tag attributes.
$attributes = [
'noindex' => '',
'nofollow' => '',
'noarchive' => '',
'nosnippet' => '',
'noimageindex' => '',
'noodp' => '',
'notranslate' => '',
'max-snippet' => '',
'max-image-preview' => '',
'max-video-preview' => ''
];
Example code snippet
The code snippet below is just an example of how this filter can be used. In the example below, All in One SEO is adding the ‘index’ and ‘nofollow’ attribute to posts.
add_filter( 'aioseo_robots_meta', 'aioseo_filter_robots_meta' );
function aioseo_filter_robots_meta( $attributes ) {
if ( is_singular() ) {
$attributes['noindex'] = 'index';
$attributes['nofollow'] = 'nofollow';
}
return $attributes;
}