最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

theme development - Available widgets is not showing up?

programmeradmin5浏览0评论

I have added theme support in functions.php file.

add_theme_support('widgets');

And register the menu still no available default widget.



class Sidebars{
    public function __construct(){
        $this->setup_hooks();
    }

    protected function setup_hooks(){
        add_action('widgets_init', [$this, 'register_sidebars']);
    }

    public function register_sidebars(){
        register_sidebar( array(
            'name'          => __( 'Main Sidebar', 'textdomain' ),
            'id'            => 'sidebar-1',
            'description'   => __( 'Widgets in this area will be shown on all posts and pages.', 'textdomain' ),
            'before_widget' => '<li id="%1$s" class="widget %2$s">',
            'after_widget'  => '</li>',
            'before_title'  => '<h2 class="widgettitle">',
            'after_title'   => '</h2>',
        ) );

    }
}

$sidebar = new Sidebars();

Here is my full code

I am not an expert but there suppose to have an option of available widgets. What am I missing?

发布评论

评论列表(0)

  1. 暂无评论