【问题标题】:How to include boostrap 4 into custom wordpress theme?如何将 bootstrap 4 包含到自定义 wordpress 主题中?
【发布时间】:2021-02-23 13:12:32
【问题描述】:

我正在开发自定义 wordpress 主题,我尝试使用 boostrap 4 代码将自定义 html 内容包含到我的页面中:

<div class="container">
  <div class="row">
    <div class="col-sm">
      One of three columns
    </div>
    <div class="col-sm">
      One of three columns
    </div>
    <div class="col-sm">
      One of three columns
    </div>
  </div>
</div>

我已根据official documentation 将本地所有 boostrap 依赖项添加到我的主题中:

function theme_scripts() {
    wp_enqueue_style( 'boostrap', get_template_directory_uri() . '/css/boostrap.min.css' );

    /* Boostrap 4 library */
    wp_enqueue_script('jquery-theme',get_template_directory_uri() . '/js/jquery-3.2.1.slim.min.js', array(), '3.2.1', true);
    wp_enqueue_script('popper', get_template_directory_uri() . '/js/popper.min.js', array(), '', true );
    wp_enqueue_script('bootstrap', get_template_directory_uri() . '/js/bootstrap.min.js', array('jquery', 'popper'), '4.0.0', true );
}

当我打开我的网页时,我看到所有列都在不同的行:(

如何将 boostrap 包含到我的 wordpress 主题中?有什么特殊的操作吗?

谢谢:D

【问题讨论】:

    标签: wordpress bootstrap-4


    【解决方案1】:

    您是否检查了文件名,因为您加载了一个名为 boostrap.min.css

    的文件

    wp_enqueue_style( 'boostrap', get_template_directory_uri() . '/css/boostrap.min.css' );

    【讨论】:

    • 哎呀。我很惭愧:(谢谢你的回复!
    • 没问题,我们以前都去过那里……相信我!
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-02-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-01-05
    相关资源
    最近更新 更多