noindex, nofollow s...
 
Avisos
Vaciar todo

noindex, nofollow si tiene parámetros específicos en la url

1 Respuestas
1 Usuarios
0 Me gustas
84 Visitas
Respuestas: 20
Admin
Topic starter
(@iguannaweb)
Miembro
Registrado: hace 3 años

A veces no queremos que se indexe una página que tenga un parámetro determinado en la url, como puede ser "orderby"

add_action( 'wp_head', 'cp_prevent_indexing_orderby' );

if(!function_exists('cp_prevent_indexing_orderby')){
    function cp_prevent_indexing_orderby () {
        if (isset($_GET['orderby'])){
            echo '<meta name="robots" content="noindex, nofollow">';
        }
    }
}

Con este código puedes meter un meta para decirle a los buscadores que no indexen ni sigan determinadas páginas que muestren el parámetro deseado en la url.

Pero si usas Yoast SEO, puedes usar otra forma:

add_filter( 'wpseo_robots', 'yoast_seo_robots_remove_single' );
/**
 * Set certain posts to noindex nofollow
 */
function yoast_seo_robots_remove_single( $robots ) {

	if (isset($_GET['orderby'])){
	     return 'noindex,nofollow'; 
       } else {
	     return $robots; 
       }
}
Etiquetas del debate