Support » Developing with WordPress » Function snippet not working to disable footer widgets in woocommerce pages

  • Hello,

    I run a woocommerce website with a genesis framework theme. The theme has Widgets I’d like to disable in the woocommerce related pages. I’m trying this snippet:

    if ( function_exists( 'is_woocommerce' ) ) {
    add_action( 'genesis_before_footer', 'remove_footer_woo' );
    function remove_footer_woo() {
    if ( is_shop() || is_page( 'support' ) || 'product' == get_post_type() || is_woocommerce() ) {
    remove_action( 'genesis_before_footer', 'genesis_footer_widget_areas' );
    remove_action('genesis_footer', 'genesis_do_footer');
    remove_action('genesis_footer', 'genesis_footer_markup_open', 5 );
    remove_action('genesis_footer', 'genesis_footer_markup_close', 15 );
    
    }}}

    The above code worked for a while and then all of a sudden the widgets started appearing again. I thought maybe it had something to do with the priorities so experimented with that, but now no matter what I do the code doesn’t work at all when used in my functions.php

    I’ve even tried specifically targeting one of the widgets:

    add_action( 'genesis_before_footer', 'remove_footer_cta' );
    function remove_footer_cta() {
    if ( is_woocommerce() ) {
    remove_action( 'genesis_before_footer', 'essence_footer_cta', 17 );
         }
    }

    But nothing. I’m not sure why this wouldn’t work even after having worked before (on and off). What could be causing this behavior?

    Warmly,

    Matt

    • This topic was modified 1 month, 2 weeks ago by  Soprano.
Viewing 3 replies - 1 through 3 (of 3 total)
  • Graham

    (@graham2621)

    Hello Matt! was there an update that may have caused this? Are you running a child theme of Genesis?

    I like your approach and would suggest running those statements outside of a conditional. And then, if the statements work, take a look at the conditional and why it was restricting the remove_action() functions.

    Let me know if there was any progress – good luck.

    Thanks Graham for following up on this.

    I don’t think I can pin point any updates relating to this as I seem to have had the widgets appear and disappear at random intervals (The code worked when I launched the new theme but then appeared all of a sudden a few weeks ago). Thought I must admit I don’t visit the shop pages very much, so I wouldn’t be able to pinpoint when it started appearing again.

    I hadn’t thought of that, I tried running the widget area removal script by itself:

    remove_action( 'genesis_before_footer', 'genesis_footer_widget_areas' );

    But it doesn’t work, neither did the removing the full footer area ‘genesis_do_footer’. I’ve tried on both my live site and my staging site (try bypass any cache plugins) and they both get the same issue.

    I do run a child theme, Essence Pro.

    Is there any reason that the remove_action on its own wouldn’t work within a function.php file?

    Thank you

    Moderator bcworkz

    (@bcworkz)

    I’m pretty sure Graham meant remove the if conditions, not the action hook. By removing the action hook, you attempt to remove actions that have not yet been added. If you still have trouble without if conditions, something has changed with the Genesis actions. We’re unable to help in these forums with the specifics of Genesis based themes. We’ve no access to its source code. You should either obtain support through your theme vendor or examine the framework code directly to determine what actions are involved and how they were added.

Viewing 3 replies - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.