Sidebar侧边栏开发

Bobby
2026-11-05 / 0 评论 / 8 阅读 / 正在检测是否收录...

Sidebar侧边栏开发

add_action('widgets_int','wpdevs_sidebars');
function wpdevs_sidebars(){
register_sidebar(

 array(
    'name' => 'Blog Sidebar',
    'id' =>'sidebar-blog',
    'description' =>'This is the Blog Sidebar.You can add your widget here.',
     'before_widget' => '<div class ="widget-wrapper">',
     'after_widget' => '</div>',
     'before_title' => '<h4 class ="widget-title">'
     'after_title'  => '</h4>'
     
 )

);
}

注册新php文件,sidebar.php
<?php if(is_active_sidebar('sidebar-blog')): ?>

<aside class = "sidebar">
   <?php dynamic_sidebar('sidebar-blog'); ?>
<aside/>

<?php endif;

调用sidebar侧边栏,<?php get_sidebar();>

调用侧边栏后,去wordpress后台找widgets
然后设置小部件

0

评论 (0)

取消