douxiduan8344
2014-09-02 10:03
浏览 44
已采纳

Wordpress Functions.php文件没有排队任何东西

I don't know why, but my functions.php file doesn't load any script/style. This is my functions.php file:

<?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');

What is the problem here? I am simply adding action to wp_enqueue_scripts and enqueue scripts/styles, but when I inspect the page, and go to Resources, there is nothing there, no style, no script.

EDIT1: Another strange thing is that my theme used to work without functions.php file, I was loading the scripts in the header, before reading more about enqueuing. Now, I created the functions.php and nothing gets imported properly. I added some random text there and no error is returned, and if I type something outside the function, it gets echoed in the html page.

My guess is that there is an error somewhere, but I don't know how to debug it, I have the WP_DEBUG set to true in wp-config, I don't really know what to do.

图片转代码服务由CSDN问答提供 功能建议

我不知道为什么,但我的functions.php文件没有加载任何脚本/样式。 这是我的functions.php文件:

 &lt;?php 
 
function promotie_load_styles(){
 / *如果这是WordPress的管理区域,请不要 做任何事情* / 
 if 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'); 
nn 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'); 
 
 //引导东西
 wp_register_script('bootstrap-js',get_template_directory_uri()。'/ js / bootstrap.min.js'); 
 wp_enqueue_script('bootstrap-  js'); 
 
 wp_register_style('bootstrap-css','// maxcdn.boots  trapcdn.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,我真的不知道该怎么做。

  • 写回答
  • 好问题 提建议
  • 追加酬金
  • 关注问题
  • 邀请回答

1条回答 默认 最新

  • douchen4547 2014-09-02 10:50
    最佳回答

    You are most probably missing wp_head() inside the <head></head> tag

    评论
    解决 无用
    打赏 举报

相关推荐 更多相似问题