php - 如何将类添加到 WordPress 中的自定义侧边栏

标签 php css wordpress

我刚刚学会了如何创建自定义 WordPress 主题。我想为我的侧边栏分配一个类以进行样式设置,但我在网上没有找到任何解释如何执行此操作的内容。我添加到 function.php 文件以注册侧边栏的代码是:

    if ( function_exists('register_sidebar') )
    register_sidebar(array(
        'id'            => 'sidebar-1',
        'description'   => __( 'Add widgets here to appear in your sidebar.', 'twentysixteen' ),
        'before_widget' => '',
        'after_widget'  => '',
        'before_title'  => '',
        'after_title'   => '',
    ));

And the code I added to my sidebar.php file is:

<?php if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar() ) : ?>
<?php endif; ?>

任何帮助将不胜感激!

最佳答案

使用 before_widget 和 after_widget 添加包装器。

关于php - 如何将类添加到 WordPress 中的自定义侧边栏,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42171695/

相关文章:

javascript - (WP) 代码可以在独立的 codepen 中运行,但不能在实时站点上运行

php - Composer 优势

php - 从另一个 PHP 脚本执行 PHP 脚本

php - 非常简单的 PHP 代码使 Apache 崩溃

php - 有哪些方法可以改进这个长 mysql 搜索查询?

css - 将 anchor 与 div 内的图像垂直对齐

javascript - mCustomScrollbar 在 wrapper 上滚动但不在 ul 上滚动

php - fatal error : Using $this when not in object context - OOPHP

javascript - d3.js 创建饼图但呈方形

wordpress - Docker Wordpress tar : <file> Cannot change ownership to uid 33, gid 33:不允许操作