Skip to content

Instantly share code, notes, and snippets.

@deeman
Last active March 9, 2022 12:17
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save deeman/3c875f03e5a7d693181cbc3e2eab2bea to your computer and use it in GitHub Desktop.
Save deeman/3c875f03e5a7d693181cbc3e2eab2bea to your computer and use it in GitHub Desktop.
(SEO) WooCommerce "No Index, No Follow" on cart, order, checkout- pages then using YOAST!
function woo_seo_noindex_special_pages () {
global $post;
$woocommerce_pages = array('cart', 'checkout', 'order-received', 'order-tracking',
'my-account', 'logout', 'lost-password', 'mijireh-secure-checkout');
$slug = get_post($post)->post_name;
if (in_array($slug, $woocommerce_pages)) {
echo '<meta name="robots" content="noindex,follow"/>' . "\n";
}
}
add_action('wpseo_head', 'woo_seo_noindex_special_pages');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment