Skip to content

Instantly share code, notes, and snippets.

@galbaras
Last active May 29, 2019 10:34
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save galbaras/6ad566fa9fd7dd8de1d5 to your computer and use it in GitHub Desktop.
Save galbaras/6ad566fa9fd7dd8de1d5 to your computer and use it in GitHub Desktop.
Make special WooCommerce pages "noindex,follow" when using Yoast SEO
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');
@dilipsam123
Copy link

Hi how to echo '' based on the menu order of first result.

I have arranged menu order 0 as priority in all pages but if the first result has menu order 1 then noindex,follow

How do I achive this on tag pages?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment