Hi Martin,
There is – in some sorts, and it’s quite tricky as to see when or where a tag isn’t or is indexed. But I tested it all out and it works as intended :).
You can give this a go and it’s not permanent. So when you remove the code the default will be back to indexing (unless the Tag is saved, more on this below).
add_filter( 'get_term', 'my_term_modifications', 9 );
/**
* Check the term.
*
* @param object|null $term The current Term.
*
* @return object|null $term
*/
function my_term_modifications( $term ) {
if ( ( is_tag() ) || ( is_admin() && isset( $term->taxonomy ) && 'post_tag' === $term->taxonomy ) ) {
//* We're on a tag or within the tag edit screen - adjust defaults
add_filter( 'the_seo_framework_term_meta_defaults', 'my_seo_term_tag_defaults' );
}
return $term;
}
/**
* Change Tag Term defaults.
*
* @param array $defaults The default Term options.
*/
function my_seo_term_tag_defaults( $defaults ) {
//* Set noindex to 1.
$defaults['noindex'] = 1;
return $defaults;
}
What this code does is the following:
1. It injects a check when the term is being fetched (post_tag, category, etc.).
2.a. When this check is on the front-end, it will see if we’re on a tag.
2.b. When this check is within the admin, it will see if “post_tag” is the taxonomy (a tag, that is).
3. Then it will adjust the defaults through The SEO Framework filter.
4. The filter will set the default value for noindex to 1.
When does this work:
a. When the Post Tag is new.
b. Or when the Post Tag has never saved while The SEO Framework is active.
So in other words, the Default will be in effect until the Tag data is saved and values have been set.
The results reflect throughout the dashboard, and you’ll see the checkbox option active in the tag edit screen.
You can deactivate the checkbox and the default will be overwritten by the settings.
I hope this helps! It’s quite hacky but it’s the only way at the moment :).
Thanks for your patience and I hope you enjoy your Sunday :).