Wordpress主题从头开始

时间:2017-07-13 13:15:04

标签: php html css wordpress styles

我正在尝试从头开发一个wordpress主题,但我对function.php有一个问题。我想添加其他样式脚本,如bootstrap和animate.css,但问题是它们没有加载“package”,当我检查链接时,我在我的css文件夹之前得到了style.css。如果我删除style.css,我可以在浏览器中查看我的文件。我该如何解决这个问题?从链接中删除style.css。

http://localhost/humlan/wp-content/themes/humlan/style.css/css/bootstrap.min.css?ver=3.0.3

这是FUNCTION.PHP中的代码

/**
 * Enqueue scripts and styles.
 */
function humlan_scripts() {
wp_enqueue_style( 'bootstrap.min', get_stylesheet_uri() . '/css/bootstrap.min.css',false,'3.0.3','all');
wp_enqueue_style( 'prettyPhoto', get_stylesheet_uri() . '/css/prettyPhoto.css',false,'1.1','all');
wp_enqueue_style( 'font-awesome.min', get_stylesheet_uri() . '/css/font-awesome.min.css',false,'1.1','all');
wp_enqueue_style( 'animate', get_stylesheet_uri() . '/css/animate.css',false,'1.1','all');
wp_enqueue_style( 'main', get_stylesheet_uri() . '/css/main.css',false,'1.1','all');
wp_enqueue_style( 'responsive', get_stylesheet_uri() . '/css/responsive.css',false,'1.1','all');
wp_enqueue_style( 'humlan-style', get_stylesheet_uri() );


    wp_enqueue_script( 'humlan-navigation', get_template_directory_uri() . '/js/navigation.js', array(), '20151215', true );

    wp_enqueue_script( 'humlan-skip-link-focus-fix', get_template_directory_uri() . '/js/skip-link-focus-fix.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 :(得分:0)

试一下

function load_styles(){
   wp_enqueue_script( 'jQuery-js', 'https://cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js');
   wp_enqueue_script( 'bootstrap-js', 'https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js', array('jquery'), '3.3.7', true );
}

不要从服务器加载css,而是使用速度相对较快的CDN链接......

答案 1 :(得分:0)

使用get_stylesheet_directory_uri() - 因为它会返回样式表的文件夹。您正在使用的内容会返回实际样式表的URI。

相关问题