• Resolved cl0ne

    (@cl0ne)


    Hi!

    So, I would like to know how to override a default behavior in Woocommerce, which is caused by the following code:

    
    function wc_page_noindex() {
    	if ( is_page( wc_get_page_id( 'cart' ) ) || is_page( wc_get_page_id( 'checkout' ) ) || is_page( wc_get_page_id( 'myaccount' ) ) ) {
    		wp_no_robots();
    	}
    }
    add_action( 'wp_head', 'wc_page_noindex' );
    

    This code blocks core pages from being detected by search engines. Problem is: my configuration puts the checkout and cart page right on the home page using Woocommerce One Page Checkout plugin. Essentially, this is the most important page on the site and yet because it has a checkout and cart, it is automatically being label “noindex”. The independent checkout page will not be used at all as a result. How can I address this? I do not care if the independent “cart” and “checkout” pages are not seen but I would like the “my account” page to also be indexed as I classify it as an important page for customers.

    Appreciate any help!

    The page I need help with: [log in to see the link]

Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Contributor Mike Jolley (a11n)

    (@mikejolley)

    remove_action( 'wp_head', 'wc_page_noindex' );

    in your theme functions.php file should do it.

    Thread Starter cl0ne

    (@cl0ne)

    Thank you for getting back to me with a solution Mike.

    Sadly, it didn’t seem to work. I’m still getting “<meta name=’robots’ content=’noindex,follow’ />”.

    ??

    Dustin Hartzler

    (@dustinhartzler)

    Automattic Happiness Engineer

    Did you add the code via the functions.php file?

    Are other functions in that file working correctly?

    Thread Starter cl0ne

    (@cl0ne)

    Hi Dustin!

    Yes, I have a lot of functions in that file and all are working just fine. I deactivated Yoast just in case. Unfortunately no change.

    The moment I disable Woocommmerce however, it goes away.

    I was having similar issues. I was able to get it removed using the following within my theme’s functions.php file.

    add_action( 'init', 'remove_wc_page_noindex' );
    function remove_wc_page_noindex(){
    	remove_action( 'wp_head', 'wc_page_noindex' );
    }
    jessepearson

    (@jessepearson)

    Automattic Happiness Engineer

    Confirmed that Austin’s snippet works.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Disable noindex on certain core pages’ is closed to new replies.