Php 第一次尝试在Wordpress和can'中注册和排队样式和脚本;我不明白它为什么会赢';行不通
第一次尝试在Wordpress中注册样式和脚本并将其排入队列,但不知道为什么它不起作用 知道我做错了什么吗?这是my functions.php文件:Php 第一次尝试在Wordpress和can'中注册和排队样式和脚本;我不明白它为什么会赢';行不通,php,wordpress,stylesheet,Php,Wordpress,Stylesheet,第一次尝试在Wordpress中注册样式和脚本并将其排入队列,但不知道为什么它不起作用 知道我做错了什么吗?这是my functions.php文件: <?php function add_theme_scripts() { wp_register_style( 'bootstrap.min', get_template_directory_uri() .'/css/bootstrap.min.css'); wp_register_script( 'bootstrap.
<?php
function add_theme_scripts() {
wp_register_style( 'bootstrap.min', get_template_directory_uri() .'/css/bootstrap.min.css');
wp_register_script( 'bootstrap.min-js', get_template_directory_uri() .'/css/bootstrap.min.js');
wp_register_script( 'script', get_template_directory_uri() .'/css/script.js');
wp_register_script( 'jquery-3.1.1', get_template_directory_uri() .'/css/jquery-3.1.1.js');
wp_enqueue_style( 'bootstrap.min' );
wp_enqueue_script( 'bootstrap.min-js' );
wp_enqueue_script( 'script' );
wp_enqueue_script( 'jquery-3.1.1' );
}
add_action( 'wp_enqueue_scripts', 'add_theme_scripts' );
?>
<!DOCTYPE html>
<html <?php language_attributes(); ?> class="no-js no-svg">
<head>
<meta charset="<?php bloginfo( 'charset' ); ?>">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="<?php bloginfo('stylesheet_url'); ?>" type="text/css" />
<link rel="profile" href="http://gmpg.org/xfn/11">
<?php wp_head(); ?>
</head>
这是我的header.php文件:
<?php
function add_theme_scripts() {
wp_register_style( 'bootstrap.min', get_template_directory_uri() .'/css/bootstrap.min.css');
wp_register_script( 'bootstrap.min-js', get_template_directory_uri() .'/css/bootstrap.min.js');
wp_register_script( 'script', get_template_directory_uri() .'/css/script.js');
wp_register_script( 'jquery-3.1.1', get_template_directory_uri() .'/css/jquery-3.1.1.js');
wp_enqueue_style( 'bootstrap.min' );
wp_enqueue_script( 'bootstrap.min-js' );
wp_enqueue_script( 'script' );
wp_enqueue_script( 'jquery-3.1.1' );
}
add_action( 'wp_enqueue_scripts', 'add_theme_scripts' );
?>
<!DOCTYPE html>
<html <?php language_attributes(); ?> class="no-js no-svg">
<head>
<meta charset="<?php bloginfo( 'charset' ); ?>">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="<?php bloginfo('stylesheet_url'); ?>" type="text/css" />
<link rel="profile" href="http://gmpg.org/xfn/11">
<?php wp_head(); ?>
</head>
我认为问题在于句柄bootstrap.min
您需要通过替换句柄中的.(点)来更改句柄。请改用-(连字符)。谢谢大家
结果是一件非常愚蠢的事。。。我工作的FTP中有一个重复的文件系统。。。因此与代码无关:/
我很感激您的回答:)再次感谢。请尝试用连字符(-)替换点(.);像bootstrap.min
到bootstrap-min
不要让别人的评论成为你自己的答案。顺便说一下,bootstrap的形式是bootstrap.min.js
或bootstrap.min.css
让我告诉你,我没有看到关于这个问题的最后一条评论。我想你也没有读过答案,如果你熟悉这个词,我对我的答案很挑剔。请阅读stackoverflow中注释和答案之间的差异。。。。。希望你在接下来的评论中更加小心,给别人打负面标记,让他们更加小心你…我想你不知道我写了什么,请阅读wordpress函数wp_enqueue_风格,并阅读如何使用“句柄”…wp文档只说句柄需要是唯一的字符串。它没有提到对允许哪些字符的限制,也没有特别提到点是个问题。正确地指出,这就是为什么我说“我想”。我总是用那种方式,我只是想用我的方式帮助他。。。