Support » Themes and Templates » Widget Area won't show on site?

  • So I’ve been struggling to figure out why my new widget are won’t work. I’m using the mango theme, once i register the widget area it shows on my widgets, then i go to apply the it to specefic area of the page, in my case it’s the header, and when i add the code, nothing happens, it’s like the code isn’t even there. This is the code to register my widget. `function mango_child_widgets_init(){

    register_sidebar( array(
    ‘name’ => ‘Main Header’,
    ‘id’ => ‘Main_Header’,
    ‘before_widget’ => ‘<aside>’,
    ‘after_widget’ => ‘</aside>’,
    ‘before_title’ => ‘<h3 class=”widget-title”>’,
    ‘after_title’ => ‘</h3>’,
    ));
    }

    add_action( ‘widgets_init’, ‘mango_child_widgets_init’);

    The second code i used to apply it to the specific place (header), i used:
    `<?php if( dynamic_sidebar(‘Main_Header’) ) : else : endif; ?>
    and i put it right under the header center, right before it ends it and after it starts it. P.S. im using a child theme and editing the header template works because if i put <h1>TEST</h1> and it works. I’ve also tried deactivating all plugins and re-activating. Is there something i need to do with a loop or something, im a newbie at this, and this so far is the thing i can’t figure out. If anyone can help me please and thank you.

Viewing 1 replies (of 1 total)
  • Hello hernanhms,
    Try this for second code:

    <?php if ( is_active_sidebar( 'Main_Header' ) ) : ?>
    	<div....>
    	<?php dynamic_sidebar( 'Main_Header' ); ?>
    	</div>
    <?php endif; ?>

    and when i add the code, nothing happens, it’s like the code isn’t even there.

    You also need to copy the header template from parent into child theme and edit the header template of child theme and call the above sidebar code to where you want to display.
    The good thing about child themes is that if it doesn’t work as you expect, all you need to do is re-select the parent theme and everything will be back to the original.

    Let me know how your widget goes!

Viewing 1 replies (of 1 total)
  • The topic ‘Widget Area won't show on site?’ is closed to new replies.