Woocommerce adds a noindex tags to certain pages. For that we receive some error on search console. Yoast try add all page for indexing where woocommerce adds noindex that's the conflict we need to resolve. One way to remove this is not set those file as index but I don't recommended because we should not index cart, my account, checkout etc. better approach is to add some code to function.php The following code snippet should help remove Cart, My Account, and Checkout for you:
| ||
* If Woocommerce and Yoast are enabled, we need to prevent Yoast from showing My Account, Checkout, and Cart in the sitemap | ||
* | ||
* @param $exclusions_array | ||
* @author Nick Jeffers @ Websites Depot Inc | ||
* @since | ||
* @return array | ||
*/ | ||
function wd_remove_woo_pages_from_yoast_sitemap( $exclusions_array ) { | ||
// make sure Woocommerce is enabled | ||
if ( function_exists( 'woocommerce_enabled' ) ) { | ||
$woocommerce_enabled = woocommerce_enabled(); | ||
} else { | ||
if ( class_exists( 'WooCommerce' ) ) { | ||
$woocommerce_enabled = true; | ||
} else { | ||
$woocommerce_enabled = false; | ||
} | ||
} | ||
// make sure yoast is enabled | ||
include_once( ABSPATH . 'wp-admin/includes/plugin.php' ); | ||
if ( is_plugin_active( 'wordpress-seo/wp-seo.php' ) || is_plugin_active( 'wordpress-seo-premium/wp-seo-premium.php' ) ) { | ||
$yoast_enabled = true; | ||
} else { | ||
$yoast_enabled = false; | ||
} | ||
// if both are enabled, lets remove the woo pages | ||
if ( $woocommerce_enabled && $yoast_enabled ) { | ||
// array of page names | ||
$woocommerce_pages_to_disable = array( | ||
'myaccount', | ||
'cart', | ||
'checkout' | ||
); | ||
// if this page exists, and doesn't return -1, we need to add the page ID to our exclusions | ||
foreach ( $woocommerce_pages_to_disable as $page_name ) { | ||
if ( wc_get_page_id( $page_name ) != -1 ) { | ||
$exclusions_array[] = wc_get_page_id( $page_name ); | ||
} | ||
} | ||
} | ||
return $exclusions_array; | ||
} | ||
} | ||
add_filter('wpseo_exclude_from_sitemap_by_post_ids', 'wd_remove_woo_pages_from_yoast_sitemap', 10, 1); |
Great. I never thought someday i leaned SEO. I have been learning Ethical Hacking. Today i also interested to learn SEO just because of you.
ReplyDeletethank you
ReplyDeletethanks
ReplyDeleteaita diye toh je kono page ei delete kora jabe shudhu 'myaccount','cart','checkout' edit korle (not_sure)......sir one request to you...fb te onk scammer ace....apni nije ekta forum site create koren....ai khane amra jara thakbo sobaike active paren...ar amra jara active thakbo tader vitor relation buildup hobe... ai khane amra annonymous vabe thakbo... ar wordpress malware removal niya ekta tutorial banan sir....plzzzzzzzzzzzzzzzzzzzzzzzzz.......... sir...plzzzzzzzzzzzzz
ReplyDeletebest practices but some problem here.Please chick it https://prnt.sc/nKJRG3U2jWbs
ReplyDelete