August 6, 2019 at 11:44 am
You guys helped me with some custom functions a while back. I’ve been placing them in the parent Virtue theme for years but I finally decided to try out the child theme created by Kadence Themes.
Unfortunately one function works but the other doesn’t.
custom_woocommerce_archive_title_link_start works but custom_kad_woocommerce_image_link_open doesn’t.
Any insight would be appreciated. Thanks in advance!
function custom_shop_functions(){
function custom_kad_woocommerce_image_link_open() {
global $product;
if($product->product_type == 'external') {
$link = $product->get_product_url();
} else {
$link = get_the_permalink();
}
echo '<a href="'.esc_url( $link).'" class="product_item_link product_img_link">';
}
add_action( 'woocommerce_before_shop_loop_item_title', 'custom_kad_woocommerce_image_link_open', 5 );
remove_action( 'woocommerce_before_shop_loop_item_title', 'kad_woocommerce_image_link_open', 5 );
function custom_woocommerce_archive_title_link_start() {
global $product;
if( $product->product_type == 'external' ) {
$link = $product->get_product_url();
} else {
$link = get_the_permalink();
}
echo '<a href="'.esc_url( $link ).'" class="product_item_link product_title_link">';
}
add_action( 'woocommerce_shop_loop_item_title', 'custom_woocommerce_archive_title_link_start', 7 );
remove_action( 'woocommerce_shop_loop_item_title', 'virtue_woocommerce_archive_title_link_start', 7 );
}
add_action('init', 'custom_shop_functions');