在functions.php里调用
//开启边栏工具
function wpkt_sidebar(){
register_sidebar(array(
'name' => '边栏1',
'id' => 'sidebar-1',
'description' => '第一个边栏',
'before_widget' => '<aside id="%1$s" class="widget %2$s">',
'after_widget' => '</aside>',
'before_title' => '<h2 class="widget-title">',
'after_title' => '</h2>',
));
}
add_action( 'widgets_init', 'wpkt_sidebar' );
前台调用: 先判断有没有添加小工具
<div class="col-md-3 pdfixr">
<div class="widget-area">
<?php if( is_active_sidebar('sidebar-1')): ?>
<?php dynamic_sidebar('sidebar-1') ?>
<?php else: ?>
暂无小工具
<?php endif; ?>
</div>
</div>