HandMyth SEO Noindex & Robots Fix

tags from HTML head to prevent Google discovery
* – Adds noindex headers to search results pages
* – Keeps robots.txt blocking (correct SEO practice)
* Version: 1.0
*/

HandMyth SEO Noindex & Robots Fix
HandMyth SEO Noindex & Robots Fix

// Disable feed link tags in HTML head (prevents Google from discovering feed URLs)
add_action(‘init’, function() {
remove_action(‘wp_head’, ‘feed_links’, 2);
remove_action(‘wp_head’, ‘feed_links_extra’, 3);
});

// Add X-Robots-Tag: noindex to search result pages
add_action(‘template_redirect’, function() {
if (is_search()) {
header(‘X-Robots-Tag: noindex, follow’, true);
}
if (is_feed()) {
header(‘X-Robots-Tag: noindex, follow’, true);
}
});

// Fix the {search_term_string} issue in translated search forms
add_filter(‘get_search_form’, function($form) {
// Replace literal {search_term_string} with empty or proper placeholder
$form = str_replace(‘{search_term_string}’, ”, $form);
return $form;
});

Voltar ao topo