在yoast中为特定类别的woocommerce产品页面设置“nofollow”

nr9pn0ug  于 2021-10-10  发布在  Java
关注(0)|答案(0)|浏览(210)

我一直试图从索引中排除特定的“批发商类别”(仅b2b_)。下面的代码似乎被yoast忽略了。或者,据我在meta标题中看到的,这些产品仍在索引和跟踪中。

add_filter( 'wpseo_googlebot', 'yoast_seo_robots_remove_single' );
add_filter( 'wpseo_bingbot', 'yoast_seo_robots_remove_single' );
add_filter( 'wpseo_robots', 'yoast_seo_robots_remove_single' );

function yoast_seo_robots_remove_single( $robots ) {
    if ( is_product() && has_term( 'b2b_only' ) ) { //check for b2b category
    return 'noindex,nofollow'; //noindex nofollow this product
    }

    else {
    return $robots; //else return robots
    }

}

我不确定是wp还是yoast否决了这一点。非常感谢您的帮助。

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题