0

I have registered two widgets in my functions.php file; however, the second one (#footer-ad) isn't showing up in the dashboard.

function mobile_mix_widgets_init() {
    register_sidebar( array(
        'name'          => __( 'Featured Videos', 'mobile-mix' ),
        'id'            => 'featured-videos',
        'description'   => '',
        'before_widget' => '',
        'after_widget'  => '',
        'before_title'  => '',
        'after_title'   => '',
    ) );

    register_sidebar( array(
        'name'          => __( 'Footer Ad (468x60)', 'mobile-mix' ),
        'id'            => 'footer-ad',
        'description'   => '',
        'before_widget' => '',
        'after_widget'  => '',
        'before_title'  => '',
        'after_title'   => '',
    ) );
}
add_action( 'widgets_init', 'mobile_mix_widgets_init' );

Here is what it looks like in the dashboard. In the area where the widget should appear, instead there is a grey horizontal line. I looked in the source and it looks like the widget has been registered since all of the data is showing up. However, for some reason, it's not showing up. Where did I go wrong?

enter image description here

  • What happens if you remove the "Youtube Channel Gallery Videos" widget from "Featured Videos" sidebar. I suspect that the "Youtube Channel Gallery Videos" widget is the culprit here. Remove it and refresh the page – Pieter Goosen Sep 9 '14 at 12:52
  • @Pieter I dragged it into the 'inactive widgets' area and refreshed, but the widget still isn't showing up. – Desi Sep 9 '14 at 13:08
  • That is funny, your code works for me – Pieter Goosen Sep 9 '14 at 13:12
  • I tried deactivating all plugins, signing in and out, still nothing... – Desi Sep 9 '14 at 13:15
0

Your code is working on my side. It seems that something else is causing this issue. I would look for anything else that is hooked to the widgets-init hook and start from there

Here is how I register multiple sidebars in my theme. I have modified it slightly to to accommodate your names

function mobile_mix_widgets_init() {
    $sidebars = array (
        'sidebar-101' => array (
            __( 'Featured Videos', 'mobile-mix' ) => __( 'SOME DESCRIPTION FOR WIDGET' ),
        ),
        'sidebar-102' => array (   
            __( 'Footer Ad (468x60)', 'mobile-mix' ) => __( 'SOME DESCRIPTION FOR THIS WIDGET' ),
        ),
    );  
    foreach ( $sidebars as $id => $sidebar ) {
        foreach ($sidebar as $name => $description) {
            register_sidebar(
                array (
                    'name'          =>  $name,
                    'id'            =>  $id,
                    'description'   =>  $description,
                    'before_widget' => '<aside id="%1$s" class="widget %2$s">',
                    'after_widget'  => '</aside>',
                    'before_title'  => '<h1 class="widget-title">',
                    'after_title'   => '</h1>',
                )
            );
        }
    }   
}
add_action( 'widgets_init', 'mobile_mix_widgets_init' );
  • Just revisiting, where you able to resolve this issue? – Pieter Goosen Sep 13 '14 at 11:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.