I’ve searched for similar topics, but the only one I found was closed without a proper solution (Plugin creating meta noindex tag).
My setup is as follows:
I’m using the theme Hello Elementor with Elementor Pro and WooCommerce, alongside the plugin Filter Everything;
I’ve set a redirect fuction that’s activated whenever the user tries to access an specific Archive page (product categories, custom product attributes or a custom taxonomy), so it redirects the user to the filtered Shop page, with the respective filters applied.
Example:
When the user tries to access the path “https://website.com/category/chairs/”, it gets redirected to “https://website.com/shop/?_category=chairs/”.
But then the redirected page comes with the folowing line right in the beginning of the <head>, like this:
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="profile" href="https://gmpg.org/xfn/11">
<meta name="robots" content="noindex, nofollow">
...Google Search Console errors brought my attention to this and I went to check out the HTML output, and somebody told me it’s a default function from Filter Everything plugin, but I need these filtered pages to get indexed.
How can I achieve that?
The current redirect function is as follows:
//Redirect product categories, attributes and custom taxonomy "ambiente" to shop filtered pageadd_action( 'template_redirect', 'custom_redirect_shop_filters' );
function custom_redirect_shop_filters() {
if ( is_product_category() || is_tax( 'ambiente' ) || is_tax( 'pa_mat-estrutura' ) || is_tax( 'pa_mat-acabamento-revestimento' ) || is_tax( 'faixa-em-promocao' ) || is_tax( 'faixa-pronta-entrega' ) ) {
$term = get_queried_object();
$base="/catalogo/?";
if ( $term && $term->taxonomy === 'ambiente' ) {
$url = $base . '_ambiente=" . $term->slug;
} elseif ( $term && $term->taxonomy === "product_cat' ) {
$url = $base . '_categoria=" . $term->slug;
} elseif ( $term && $term->taxonomy === "faixa-em-promocao' ) {
$url = $base . '_em-promocao=' . $term->slug;
} elseif ( $term && $term->taxonomy === 'faixa-pronta-entrega' ) {
$url = $base . '_pronta-entrega=" . $term->slug;
} elseif ( $term && $term->taxonomy === "pa_mat-estrutura' ) {
$url = $base . '_material-da-estrutura=" . $term->slug;
} elseif ( $term && $term->taxonomy === "pa_mat-acabamento-revestimento' ) {
$url = $base . '_material-do-acabamento-revestimento=' . $term->slug;
} else {
$url = wc_get_page_permalink( 'shop' );
}
wp_safe_redirect( $url );
exit;
}
}
What I’ve tried adding, but wouldn’t remove the noindex, nofollow tags:
// Remove noindex, nofollow tags
add_filter('wp_robots', 'remove_noindex_nofollow', PHP_INT_MAX - 1);function remove_noindex_nofollow($robots) {
unset($robots['noindex']);
unset($robots['nofollow']);
return $robots;
}
Any help is much appreciated!
Thanks in advance,
Pedro
