Is_front_page not working? - by kristofferj

This topic has 8 replies, 4 voices, and was last updated 8 years, 5 months ago ago by Stan Russell

  • Avatar: kristofferj
    kristofferj
    Participant
    October 28, 2015 at 19:38

    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?

    7 Answers
    Avatar: Eva
    Eva Kemp
    Support staff
    October 29, 2015 at 17:57

    Hello,

    Please provide us with FTP and wp-admin panel credentials in Private Content.

    Regards,
    Eva Kemp.

    Avatar: kristofferj
    kristofferj
    Participant
    October 29, 2015 at 18:12

    I don’t own the website so I can’t give out details.
    Could you just correct the function I wrote so it will work with Woopress theme?

    Avatar: Jack Richardson
    Jack Richardson
    Support staff
    October 30, 2015 at 12:02

    Hello,

    It’s difficult to investigate the issue without seeing wp-admin panel.
    Is your page set as front page in Settings > Reading?

    Best regards,
    Jack Richardson.

    Avatar: kristofferj
    kristofferj
    Participant
    October 30, 2015 at 12:37

    Managed to solve this.
    My next problem is how do i make a Woocommerce thumbnail image clickable, so when clicked one is forwarded to the single product page?

    Avatar: Jack Richardson
    Jack Richardson
    Support staff
    October 30, 2015 at 14:03

    Hello,

    There is no such option in the theme, you should refer to Woocommerce support, also read this article:
    https://slocumthemes.com/2015/10/how-to-make-woocommerce-thumbnails-clickable/

    Best regards,
    Jack Richardson.

    Avatar: kristofferj
    kristofferj
    Participant
    October 31, 2015 at 21:59

    I tried that solution but it didn’t work, I will try woocommerce support.

    Avatar: stan
    Stan Russell
    Participant
    November 2, 2015 at 08:31

    Hello kristofferj,

    we wish you with Woocommerce support to solve this problem in no time.

    Regards,
    Stan Russell.

  • Viewing 8 results - 1 through 8 (of 8 total)

You must be logged in to reply to this topic.Log in/Sign up

We're using our own and third-party cookies to improve your experience and our website. Keep on browsing to accept our cookie policy.