Notice: These forums are now retired and closed. For active support, please Submit a Ticket or visit our official WordPress.org community pages.
Kadence Theme | Kadence Blocks | Starter Templates | WooCommerce Email Designer | Ascend | Virtue | Pinnacle

Need help with product title URL function

Home / Forums / Virtue Theme / Need help with product title URL function

This topic is: Resolved
[Resolved]
Posted in: Virtue Theme
May 31, 2018 at 9:25 am

Greetings:

I noticed that you moved content-product code to functions in version 4.5.5. Unfortunately for me, I was changing this little bit:

<a href="<?php the_permalink(); ?>"

To This:

<a href="<?php echo esc_url( $product->get_product_url() ) ?>

In the past you helped me with point image URLs from permalink to the product URL. This is the code:

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 );
}

add_action('init', 'custom_shop_functions');

Would you kindly help me change the product title URL from permalink to product URL with a similar function?

Thanks!

is the “store” page. If you would like to see in action.

  • The forum ‘Virtue Theme’ is closed to new topics and replies.