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.

  • 写回答

1条回答 默认 最新

  • douchen4547 2014-09-02 10:50
    关注

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

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 有偿求码,CNN+LSTM实现单通道脑电信号EEG的睡眠分期评估
  • ¥15 没有证书,nginx怎么反向代理到只能接受https的公网网站
  • ¥50 成都蓉城足球俱乐部小程序抢票
  • ¥15 yolov7训练自己的数据集
  • ¥15 esp8266与51单片机连接问题(标签-单片机|关键词-串口)(相关搜索:51单片机|单片机|测试代码)
  • ¥15 电力市场出清matlab yalmip kkt 双层优化问题
  • ¥30 ros小车路径规划实现不了,如何解决?(操作系统-ubuntu)
  • ¥20 matlab yalmip kkt 双层优化问题
  • ¥15 如何在3D高斯飞溅的渲染的场景中获得一个可控的旋转物体
  • ¥88 实在没有想法,需要个思路