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

Find out the reason that the Styles and scripts in the theme are loading properly in localhost but Not in server after deploying

programmeradmin2浏览0评论

My custom theme works well on my localhost, but when I upload it to my domain, it can not enqueue any of my styles and javascript. I have everything done correctly.

wp_head & wp_footer installed, wp_enqueue_script & wp_enqueue_style defined for each element.

Functions.php

function load_stylesheets() {

    wp_register_style('bootstrap', '.1.1/css/bootstrap.min.css');
    wp_enqueue_style('bootstrap');

     wp_register_style('font', get_template_directory_uri().'/css/font-awesome.min.css', array(), 1, 'all');
    wp_enqueue_style('font');

     wp_register_style('animate', get_template_directory_uri().'/css/animate.css', array(), 1, 'all');
    wp_enqueue_style('animate');

     wp_register_style('owl', get_template_directory_uri().'/css/owl.carousel.css', array(), 1, 'all');
    wp_enqueue_style('owl');

     wp_register_style('theme', get_template_directory_uri().'/css/owl.theme.default.min.css', array(), 1, 'all');
    wp_enqueue_style('theme');

    wp_register_style('tooplate', get_template_directory_uri().'/css/tooplate-style.css', array(), 1, 'all');
    wp_enqueue_style('tooplate');

    wp_register_style('stylesolo', get_template_directory_uri().'/css/stylesolo.css', array(), 1, 'all');
    wp_enqueue_style('stylesolo');

    wp_register_style('style', get_template_directory_uri().'/css/style.css', array(), 1, 'all');
    wp_enqueue_style('style');

    wp_register_style('datepicker', '.9.0/css/bootstrap-datepicker.min.css');
    wp_enqueue_style('datepicker');

}
add_action('wp_enqueue_scripts','load_stylesheets');


function addjs() {

     wp_register_script('jquery', '.4.1.min.js', array( 'jquery' ),'',true );
    wp_enqueue_script('jquery');
     wp_register_script('popper', '/[email protected]/dist/umd/popper.min.js');
    wp_enqueue_script('popper');
     wp_register_script('bootstrap', '.4.1/js/bootstrap.min.js');
    wp_enqueue_script('bootstrap');
     wp_register_script('sticky', get_template_directory_uri().'/js/jquery.sticky.js', array(),  1, 1, 1);
    wp_enqueue_script('sticky');
     wp_register_script('stellar', get_template_directory_uri().'/js/jquery.stellar.min.js', array(),  1, 1, 1);
    wp_enqueue_script('stellar');
     wp_register_script('wow', get_template_directory_uri().'/js/wow.min.js', array(),  1, 1, 1);
    wp_enqueue_script('wow');
     wp_register_script('smoothscroll', get_template_directory_uri().'/js/smoothscroll.js', array(),  1, 1, 1);
    wp_enqueue_script('smoothscroll');
     wp_register_script('owl', get_template_directory_uri().'/js/owl.carousel.min.js', array(),  1, 1, 1);
    wp_enqueue_script('owl');
        wp_enqueue_script( 'customjsjs', get_template_directory_uri().'/js/customjs.js', array( 'jquery'), '1.0.0', true );    
    wp_localize_script( 'customjsjs', 'MBAjax', array( 'ajaxurl' => admin_url( 'admin-ajax.php' ) ) );
    wp_enqueue_script('jquery-form');

     wp_register_script('datepicker', '.9.0/js/bootstrap-datepicker.min.js');
    wp_enqueue_script('datepicker');

        wp_enqueue_script( 'custom_js', get_template_directory_uri().'/js/custom.js', array( 'jquery'), '1.0.0', true );
        wp_localize_script( 'custom_js', 'ajax_object', array(
            'ajaxurl' => admin_url( 'admin-ajax.php' ),
        ));
}
add_action('wp_enqueue_scripts','addjs');

I do not know what i am doing wrong, i have looked up alot of solutions but seems like my code is correct. Can anyone tell me what might be the problem.

与本文相关的文章

发布评论

评论列表(0)

  1. 暂无评论