Widgetizing Theme: I tried to add a widget area to page.php, what am I missing?
-
I’ve followed the instructions at https://codex.www.ads-software.com/Widgetizing_Themes. I added this to functions.php:
function arphabet_widgets_init() { register_sidebar( array( 'name' => 'Main widget', 'id' => 'main_widget_area', 'before_widget' => '<div>', 'after_widget' => '</div>', 'before_title' => '<h2 class="rounded">', 'after_title' => '</h2>', ) ); } add_action( 'widgets_init', 'arphabet_widgets_init' );
and I added this to page.php:
<?php if ( is_active_sidebar( 'main_widget_area' ) ) : ?> <div id="main-widget" class="widget-area main-widget"> <?php dynamic_sidebar( 'main_widget_area' ); ?> </div><!-- #primary-sidebar --> <?php endif; ?>
but when I edit a page on my site, I don’t see any way to add widget to this new area. I’m not sure if the widget area has not been created, or if I’m trying to edit the page in the wrong way. What am I missing?
- The topic ‘Widgetizing Theme: I tried to add a widget area to page.php, what am I missing?’ is closed to new replies.