Logo Pupungbp.com

Need a WordPress expert help?

Adding Widget Area to Child Theme

Last Updated: October 6, 2013 | Reading Time: < 1 minute

If you work on Child Theme, to add widget must follow the parent’s theme rule. Or if you makes a parent theme, make sure it’s follow-able by child theme to modify it.
[php]
function new_childtheme_sidebars() {
register_sidebar(array(
‘name’ => ‘Sidebar Sidebar’,
‘before_widget’ => ‘<div class="item">’,
‘after_widget’ => ‘</div>’,
‘before_title’ => ‘<h3 class="sub">’,
‘after_title’ => ‘</h3>’,
));
register_sidebar(array(
‘name’ => ‘Footer Widget’,
‘before_widget’ => ‘<div class="item">’,
‘after_widget’ => ‘</div>’,
‘before_title’ => ‘<h3 class="sub">’,
‘after_title’ => ‘</h3>’,
));
}
add_action( ‘widgets_init’, ‘new_childtheme_sidebars’, 11 );
[/php]
Parent theme, if not defined, take hook priority at 10. Child theme, must take the lower priority to be executed after parent theme, we use 11 on the code above.

Looking for an affordable WordPress solution?

We offer budget-friendly WordPress website development services to meet your needs. Prices start at $10.

Related Posts

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.