2014-07-17 08:35
浏览 56

Functions.php wordpress不适用于样式表或jquery

I am making my first custom wordpress theme and am running into problems with functions.php

I am using bootstrap too so i want to include bootstrap stylesheets to wp i currently do it this way-:


@import url('css/bootstrap.css');
@import url('css/font-awesome.css');

I understand that i can use functions.php to do the same, so i wrote a custom function and tried to do it like this-:


/* Theme setup */

/* Add bootstrap support to the Wordpress theme*/

function theme_add_bootstrap() {
    wp_enqueue_style( 'bootstrap-css', get_template_directory_uri().'/css/bootstrap.css' );
    wp_enqueue_style( 'style-css', get_template_directory_uri().'/css/font-awesome.css' );
    wp_enqueue_script( 'bootstrap-js', get_template_directory_uri().'/js/bootstrap.js', array(), '3.0.0', true );

add_action( 'wp_enqueue_scripts', 'theme_add_bootstrap' );


This does not seem to work. Neither does functions.php load the wp jquery or the bootstrap.js

Can anyone shed some light onto this matter for me? I would be ever grateful. This is not a child theme its a custom theme.

  • 写回答
  • 好问题 提建议
  • 关注问题
  • 收藏
  • 邀请回答

1条回答 默认 最新

  • duanliangman5398 2014-07-17 08:59

    Try registering your scripts before you enqueue them. For example:

    function my_enqueue_scripts() {
        // Register Bootstrap JS.
        wp_register_script( 'bootstrap-js', get_template_directory_uri() . '/js/bootstrap.min.js', array( 'jquery' ), NULL, true );
        // Enqueue Bootstrap JS.
        wp_enqueue_script( 'bootstrap-js' );
    add_action( 'wp_enqueue_scripts', 'my_enqueue_scripts' );
    解决 无用
    打赏 举报

相关推荐 更多相似问题