最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

wp enqueue style - Stylesheets and scripts not loading

programmeradmin1浏览0评论
function spartans_styles(){
    wp_enqueue_style( 'maincss', get_stylesheet_uri());
    wp_enqueue_style('mybootstrap', get_template_directory_uri() . '/assets/css/mybootstrap.css');
    wp_enqueue_script('myscript', get_template_directory_uri() . '/assets/js/spartanscripts.js');
    wp_enqueue_style('custom', get_template_directory_uri(). '/assets/css/custom.css');
    wp_enqueue_style('GoogleFonts', ';display=swap');
    wp_enqueue_style('editor-styles', get_template_directory_uri(). '/assets/css/editor-style.css');


    wp_enqueue_style( 'bootstrap', get_template_directory_uri() . '/assets/css/mybootstrap.css', array(), '1.1', 'all');


    // wp_enqueue_style('bootstrapcdn', '.4.1/css/bootstrap.min.css');

 }

add_action('wp_enqueue_scripts', 'spartans_styles');
function spartans_styles(){
    wp_enqueue_style( 'maincss', get_stylesheet_uri());
    wp_enqueue_style('mybootstrap', get_template_directory_uri() . '/assets/css/mybootstrap.css');
    wp_enqueue_script('myscript', get_template_directory_uri() . '/assets/js/spartanscripts.js');
    wp_enqueue_style('custom', get_template_directory_uri(). '/assets/css/custom.css');
    wp_enqueue_style('GoogleFonts', 'https://fonts.googleapis/css?family=Roboto&display=swap');
    wp_enqueue_style('editor-styles', get_template_directory_uri(). '/assets/css/editor-style.css');


    wp_enqueue_style( 'bootstrap', get_template_directory_uri() . '/assets/css/mybootstrap.css', array(), '1.1', 'all');


    // wp_enqueue_style('bootstrapcdn', 'https://stackpath.bootstrapcdn/bootstrap/4.4.1/css/bootstrap.min.css');

 }

add_action('wp_enqueue_scripts', 'spartans_styles');
Share Improve this question edited Feb 10, 2020 at 18:56 butlerblog 5,1213 gold badges28 silver badges44 bronze badges asked Feb 10, 2020 at 16:34 Barot UdayBarot Uday 11 bronze badge
Add a comment  | 

1 Answer 1

Reset to default 0

You will need to add . '/style.css' to you first enqueue to actually load that file. Also, depending on your server's settings you may encounter problems with loading edited versions of your style sheets if you don't include a version number as the fourth parameter to wp_enqueue_style.

Finally, you may want to check your code whether you are registering the same handles with different parameters elsewhere (for instance in a parent theme). If they are registered first with a dependency (third parameter) and that file isn't loaded, then these will not enqueue either.

发布评论

评论列表(0)

  1. 暂无评论