首页 > 解决方案 > 如何将 boostrap 4 包含到自定义 wordpress 主题中?

问题描述

我正在研究自定义 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>

根据官方文档,我已将本地所有 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

标签: wordpressbootstrap-4

解决方案


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

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


推荐阅读