I’m trying to call a function only on front page but the usually condition for doin that doesn’t work for me. Here is what i am trying to do.
* replace add to cart with view product */
function remove_loop_button(){
if ( is_front_page() ) {
remove_action( ‘woocommerce_after_shop_loop_item’, ‘woocommerce_template_loop_add_to_cart’, 9 );
}
}
add_action(‘init’,’remove_loop_button’);
add_action(‘woocommerce_after_shop_loop_item’,’replace_add_to_cart’);
function replace_add_to_cart() {
if ( is_front_page() ) {
global $product;
$link = $product->get_permalink();
echo do_shortcode(‘View product‘);
}
}
The problem is is_front_page() won’t identify the frontpage, cause the function works without that condition. So i wonder if there is anything i have done wrong?