Here is a solution to remove the meta “noindex” which causes an issue for the myaccount page to be indexed in google, because some people want it to appear for their clients to easy find the login page.
The function match the my-account page and then remove the meta
function remove_wc_page_noindex(){
$url = $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI'];
if ( false !== strpos( $url, 'my-account' ) ) {
remove_action( 'wp_head', 'wc_page_noindex' );
}
}
add_action( 'init', 'remove_wc_page_noindex' );
My question: is there is a way to directly locate the my account page instead of matching part of the url?
2
Answers
You can get more details about the conditional tags here.
Since WP 5.7, Woocommerce uses the wp_robots filter. If
remove_action( 'wp_head', 'wc_page_noindex' )
did not work for you, then you can try the following: