【发布时间】:2014-10-26 13:31:54
【问题描述】:
我不知道为什么,但是我的 functions.php 文件没有加载任何脚本/样式。这是我的functions.php文件:
<?php
function promotie_load_styles() {
/* If this is the admin area of WordPress, don't do anything */
if( is_admin() )
return;
wp_enqueue_script('latest-jquery','https://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js');
wp_enqueue_style('fonts', 'http://fonts.googleapis.com/css?family=PT+Sans');
wp_register_style('style', get_template_directory_uri() . '/style.css');
wp_enqueue_style('style');
wp_register_script('html5shiv', 'https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js');
wp_enqueue_script('html5shiv');
wp_register_script('respond','https://oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js');
wp_enqueue_script('respond');
// bootstrap stuff
wp_register_script('bootstrap-js', get_template_directory_uri() . '/js/bootstrap.min.js');
wp_enqueue_script('bootstrap-js');
wp_register_style('bootstrap-css', '//maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css');
wp_enqueue_style('bootstrap-css');
}
add_action('wp_enqueue_scripts', 'promotie_load_styles');
这里有什么问题?我只是在 wp_enqueue_scripts 和排队脚本/样式中添加操作,但是当我检查页面并转到资源时,那里什么都没有,没有样式,没有脚本。
EDIT1:另一个奇怪的事情是我的主题过去没有functions.php文件,我在标题中加载脚本,然后再阅读更多关于排队的信息。现在,我创建了 functions.php 并没有正确导入任何内容。我在那里添加了一些随机文本并且没有返回错误,如果我在函数之外输入了一些内容,它会在 html 页面中得到回显。
我的猜测是某处有错误,但我不知道如何调试它,我在 wp-config 中将 WP_DEBUG 设置为 true,我真的不知道该怎么做。
【问题讨论】:
-
这个脚本在这里工作。您可能正在以管理员身份登录
-
我删除了那行,毫无疑问,仍然没有成功,什么都没有加载。