-
-
Save lukecarbis/c8770e1a0b4248a2dbf7 to your computer and use it in GitHub Desktop.
WooCommerce Yoast SEO noindex rule
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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