先在theme的functions.php中的widgets_init添加如下代码进行注册:
register_sidebar( array(
‘name‘ => __( ‘Service Area‘, ‘astrid‘ ) . $i,
‘id‘ => ‘service_area‘,
‘description‘ => ‘‘,
‘before_widget‘ => ‘<aside id="%1$s" class="widget %2$s">‘,
‘after_widget‘ => ‘</aside>‘,
‘before_title‘ => ‘<h3 class="widget-title">‘,
‘after_title‘ => ‘</h3>‘,
) );
最后,在需要放置widget area的位置添加如下代码:
<?php if (!dynamic_sidebar(‘service_area‘)) : ?>
[ do default stuff if no widgets ]
<?php endif; ?>
时间: 2024-12-29 23:12:02