admin管理员组文章数量:1384254
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.
本文标签:
版权声明:本文标题:Find out the reason that the Styles and scripts in the theme are loading properly in localhost but Not in server after deploying 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744527978a2610858.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论