从头开始的wordpress主题不起作用

时间:2017-07-13 20:46:08

标签: javascript php html wordpress function

我正在尝试从头开发一个wordpress主题,但我对function.php有一些问题。我想添加额外的javascripts,但问题是他们没有加载“包”,当我从浏览器检查链接时,我可以看到他们没有像我的样式表一样下载

function humlan_scripts() {

    wp_enqueue_style( 'bootstrap.min', get_stylesheet_directory_uri() . ' 
    /css/bootstrap.min.css',false,'3.0.3','all');
    wp_enqueue_style( 'prettyPhoto', get_stylesheet_directory_uri() . 
    '/css/prettyPhoto.css',false,'1.1','all');
    wp_enqueue_style( 'font-awesome.min', get_stylesheet_directory_uri() . 
    '/css/font-awesome.min.css',false,'1.1','all');
    wp_enqueue_style( 'animate', get_stylesheet_directory_uri() . 
    '/css/animate.css',false,'1.1','all');
    wp_enqueue_style( 'main', get_stylesheet_directory_uri() . 
    '/css/main.css',false,'1.1','all');
    wp_enqueue_style( 'responsive', get_stylesheet_directory_uri() . 
    '/css/responsive.css',false,'1.1','all');

    wp_enqueue_script( 'jquery', get_stylesheet_directory_uri() . 
    '/js/jquery.js', array(), '20151215', true );
    wp_enqueue_script( 'bootstrap.min', get_stylesheet_directory_uri() . 
    '/js/bootstrap.min.js', array(), '20151215', true );
    wp_enqueue_script( 'smoothscroll', get_stylesheet_directory_uri() . 
    '/js/smoothscroll.js', array(), '20151215', true );
    wp_enqueue_script( 'jquery.isotope.min', get_stylesheet_directory_uri() . ' 
    /js/jquery.isotope.min.js', array(), '20151215', true );
    wp_enqueue_script( 'jquery.prettyPhoto', get_stylesheet_directory_uri() . 
    '/js/jquery.prettyPhoto.js', array(), '20151215', true );
    wp_enqueue_script( 'jquery.parallax', get_stylesheet_directory_uri() . 
    '/js/jquery.parallax.js', array(), '20151215', true );
    wp_enqueue_script( 'main', get_stylesheet_directory_uri() . '/js/main.js', 
    array(), '20151215', true );

      if ( is_singular() && comments_open() && get_option( 'thread_comments' ) ) {
            wp_enqueue_script( 'comment-reply' );
      }
    }

add_action( 'wp_enqueue_scripts', 'humlan_scripts' );

问题是如何解决?

谢谢!

2 个答案:

答案 0 :(得分:1)

wp_enqueue_style & wp_enqueue_script 函数始终需要排队文件的URL。现在,当您使用 get_stylesheet_directory_uri()时,它会尝试从主题文件夹中的 css 文件夹加载它。因此,请检查文件是否在该位置呈现。或者您可以使用“https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css”之类的网址,因此该文件将从网址加载。

注意:使用 get_template_directory_uri()代替 get_stylesheet_directory_uri()

希望有所帮助

答案 1 :(得分:1)

我认为这是文件拼写错误

请更新function.php functions.php

相关问题