Skip to content

Instantly share code, notes, and snippets.

@lukecarbis
Forked from galbaras/gist:6ad566fa9fd7dd8de1d5
Last active August 29, 2015 14:02
Show Gist options
  • Save lukecarbis/c8770e1a0b4248a2dbf7 to your computer and use it in GitHub Desktop.
Save lukecarbis/c8770e1a0b4248a2dbf7 to your computer and use it in GitHub Desktop.
WooCommerce Yoast SEO noindex rule
function woo_seo_noindex_special_pages () {
global $post;
$woocommerce_pages = array(
wc_get_page_id( 'myaccount' ),
wc_get_page_id( 'edit_address' ),
wc_get_page_id( 'cart' ),
wc_get_page_id( 'checkout' ),
wc_get_page_id( 'pay' ),
wc_get_page_id( 'view_order' ),
);
if ( in_array( $post->ID, $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