Support » Theme: Storefront » How to remove storefront_homepage_content() action

  • Hello guys,

    I am trying to remove storefront_homepage_content() function in Storefront child theme and replace it with my own. So I wrote this function…

    
    function shs_remove_actions_parent_theme() {
       remove_action('homepage', 'storefront_homepage_content', 5); // doesnt work
    };
    add_action( 'init', 'shs_remove_actions_parent_theme', 1);
    

    …which should remove it, but it doesnt. And I have no idea why, because similar code…

    
    function shs_remove_actions_parent_theme() {
       remove_action('storefront_homepage', 'storefront_homepage_header', 10); //works
       remove_action('storefront_homepage', 'storefront_page_content', 20); //works
    };
    add_action( 'init', 'shs_remove_actions_parent_theme', 1);
    

    …works like a charm.

    I know, that storefront_homepage_content() is a pluggapble function so simply using it in my plugin which I am developing should be enough, but on one of my sites I am getting error “plugin could not be activated because it triggered a fatal error. -> cannot redeclare function storefront_homepage_content()” error so removing action and hooking my own function with the same name MUST work every time.

    For now, I have simply deleted storefront_homepage_content() from parent theme (see link) and it works but I hate this nasty workaround and want my plugin to work properly every time.

    Can anyone, please, help? How can I remove storefront_homepage_content() function before hooking my own with the same name?

    Thank you very much.

    The page I need help with: [log in to see the link]

Viewing 2 replies - 1 through 2 (of 2 total)
  • Mikey Arce

    (@mikeyarce)

    Automattic Happiness Engineer

    Hi @mirio,

    The problem is that your priority was 5 but it should be 10. This should work:

    function shs_remove_actions_parent_theme() {
       remove_action('homepage', 'storefront_homepage_content', 10); // doesnt work
    };
    add_action( 'init', 'shs_remove_actions_parent_theme', 1);
    Thread Starter Mirek Hovorka

    (@mirio)

    Great! Problem was priority. I am using plugins to find out what hooks where and with what priority, but it seems that only reliable option is to search through source code itself…

    Thank you very much!

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘How to remove storefront_homepage_content() action’ is closed to new replies.