Created
March 22, 2017 16:23
-
-
Save EricBusch/8ae4a60bcbfa092607daf058ab61e91f to your computer and use it in GitHub Desktop.
This code allows you to add a rel="nofollow" to your WooCommerce products that appear in the loop. [datafeedr]
This file contains 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
<?php | |
/** | |
* Remove the woocommerce_template_loop_product_link_open() function from the | |
* WooCommerce "woocommerce_before_shop_loop_item" action. | |
* | |
* @see remove_action() | |
*/ | |
add_action( 'wp_head', 'mycode_remove_woocommerce_template_loop_product_link_open' ); | |
function mycode_remove_woocommerce_template_loop_product_link_open() { | |
remove_action( 'woocommerce_before_shop_loop_item', 'woocommerce_template_loop_product_link_open', 10 ); | |
} | |
/** | |
* Attach our own function to use in place of the woocommerce_template_loop_product_link_open() function to | |
* the WooCommerce "woocommerce_before_shop_loop_item" action. | |
* | |
* @see get_the_permalink() | |
*/ | |
add_action( 'woocommerce_before_shop_loop_item', 'mycode_template_loop_product_link_open', 20 ); | |
function mycode_template_loop_product_link_open() { | |
echo '<a href="' . get_the_permalink() . '" rel="nofollow" class="woocommerce-LoopProduct-link">'; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment