Quantcast
Channel: Topic Tag: action | WordPress.org
Viewing all articles
Browse latest Browse all 892

ClemC on "widgets_init actions not fired from functions.php's child theme"

$
0
0

I need to add new sidebars for using them accordingly on different pages throughout my shop.
I use Woocommerce and my own Storefront child theme.
This is a snippet of what is in functions.php file of the child theme.

add_action( 'init', 'init_storefront_child' );

function init_storefront_child() {

    // It seems Wordpress doesn't take into consideration the 2 lines below.
    remove_action( 'widgets_init', 'storefront_widgets_init' ); // Not fired (or overrided by something)
    add_action( 'widgets_init', 'storefront_child_widgets_init' ); // Not fired (or overrided by something)
}

function storefront_child_widgets_init() {

    register_sidebar( array(
        'name'          => __( 'Blog Sidebar' ),
        'id'            => 'blog',
        'description'   => 'Sidebar displaying in blog.',
        'before_widget' => '<aside id="%1$s" class="widget %2$s">',
        'after_widget'  => '</aside>',
        'before_title'  => '<h3 class="widget-title">',
        'after_title'   => '</h3>',
    ) );
}

So the sidebars in 'Appearance > Widgets' menu don't change and stay the same as originally.
I tried to change the code directly in storefront theme files and it works but that's not at all the solution.

What's happen with the 'widgets_init' hook in functions.php's child theme?

Thanks by advance.


Viewing all articles
Browse latest Browse all 892

Trending Articles