Action Hook since 2.2.0

widgets_init

Fires when it's time to register widgets and sidebars

Description

widgets_init is exclusively for register_sidebar() and register_widget() calls — nothing else belongs here.

When it runs

During init processing, after core's own default widgets are registered.

Signature

do_action( 'widgets_init' );

Examples

Basic

add_action( 'widgets_init', function() {
    register_sidebar( [
        'name' => 'Footer Widgets',
        'id'   => 'footer-widgets',
        'before_widget' => '<div class="widget %2$s">',
        'after_widget'  => '</div>',
    ] );
} );

Register a footer widget area for the theme.

Common Use Cases

  • Register sidebar/widget areas
  • Register custom WP_Widget classes
  • Unregister default widgets

Common mistakes

  • Calling register_sidebar() outside widgets_init — the sidebar silently never appears in Appearance > Widgets

Related hooks

FAQ

Why doesn't my sidebar show up in the widgets screen?

register_sidebar() must run on the widgets_init hook — calling it earlier or later means WordPress never registers the widget area.

Source: wp-includes/widgets.php

Group wizard

One session: this hook, then each related_hooks entry. Walk it and tell us what to change.

widgets_init → after_setup_theme

functions.php — widgets_init
functions.php
PHP widgets_init · Hook 1 of 2 · Step 1 of 6

Practice the widgets_init WordPress action hook in our interactive sandbox — a VS Code-style editor with a step-by-step widgets_init tutorial, add_action exercises, and instant feedback. No local WordPress install required.