Problem in functions.php file

时间:2018-06-04 作者:Dhiraj kadam

我正在尝试使用functions.php. 以下是我迄今为止所做的工作:

 <?php

    function blogroom() {

        wp_enqueue_style(\'bootstrap\',  get_stylesheet_directory_uri() . \'/assets/lib/bootstrap/dist/css/bootstrap.min.css\');
        wp_enqueue_style(\'loaders\',  get_stylesheet_directory_uri() . \'/assets/lib/loaders.css/loaders.min.css\');
        wp_enqueue_style(\'iconsmind\',  get_stylesheet_directory_uri() . \'/assets/lib/iconsmind/iconsmind.css\');
        wp_enqueue_style(\'hamburgers\',  get_stylesheet_directory_uri() . \'/assets/lib/hamburgers/dist/hamburgers.min.css\');
        wp_enqueue_style(\'font-awesome-css\',  get_stylesheet_directory_uri() . \'/assets/lib/font-awesome/css/font-awesome.min.css\');
        wp_enqueue_style(\'theme-style\',  get_stylesheet_directory_uri() . \'/assets/css/style.css\');
        wp_enqueue_style(\'theme-style\',  get_stylesheet_directory_uri() . \'/assets/css/custom.css\');
        wp_register_script( \'bootstrap-js\', get_template_directory_uri() . \'/assets/lib/bootstrap/dist/js/bootstrap.min.js\');
        wp_register_script( \'imageloaded\', get_template_directory_uri() . \'/assets/lib/imagesloaded/imagesloaded.pkgd.min.js\', array( \'bootstrap-js\' ) );
        wp_register_script( \'tweenmax\', get_template_directory_uri() . \'/assets/lib/gsap/src/minified/TweenMax.min.js\', array(\'imageloaded\') );
        wp_register_script( \'scroll-to-plugin\', get_template_directory_uri() . \'/assets/lib/gsap/src/minified/plugins/ScrollToPlugin.min.js\', array(\'tweenmax\') );
        wp_register_script( \'customToEase\', get_template_directory_uri() . \'/assets/lib/CustomEase.min.js\', array(\'scroll-to-plugin\') );
        wp_register_script( \'configJs\', get_template_directory_uri() . \'/assets/js/config.js\', array(\'customToEase\') );
        wp_register_script( \'zanimation\', get_template_directory_uri() . \'/assets/js/zanimation.js\', array(\'configJs\') );
        wp_register_script( \'corejs\', get_template_directory_uri() . \'/assets/js/core.js\', array(\'zanimation\') );
        wp_register_script( \'mainjs\', get_template_directory_uri() . \'/assets/js/main.js\', array(\'corejs\') );
        wp_enqueue_script( \'mainjs\' );    
     }

    add_action( \'wp_enqueue_scripts\', \'blogroom\' );


?>
在这里,这只加载我的CSS文件,而不加载我的js文件。没有加载任何javascript文件。有人能帮忙吗?

2 个回复
SO网友:Jignesh Patel

请更换wp_register_scriptwp_enqueue_script

wp\\u register\\u脚本是加载排队后唯一不排队的寄存器脚本。

SO网友:Akshat

您需要将脚本排队,排队时会自动注册,您可以通过以下方式替换代码段:,

<?php   
function blogroom() {
    wp_enqueue_style(\'bootstrap\',  get_stylesheet_directory_uri() . \'/assets/lib/bootstrap/dist/css/bootstrap.min.css\');
    wp_enqueue_style(\'loaders\',  get_stylesheet_directory_uri() . \'/assets/lib/loaders.css/loaders.min.css\');
    wp_enqueue_style(\'iconsmind\',  get_stylesheet_directory_uri() . \'/assets/lib/iconsmind/iconsmind.css\');
    wp_enqueue_style(\'hamburgers\',  get_stylesheet_directory_uri() . \'/assets/lib/hamburgers/dist/hamburgers.min.css\');
    wp_enqueue_style(\'font-awesome-css\',  get_stylesheet_directory_uri() . \'/assets/lib/font-awesome/css/font-awesome.min.css\');
    wp_enqueue_style(\'theme-style\',  get_stylesheet_directory_uri() . \'/assets/css/style.css\');
    wp_enqueue_style(\'theme-style\',  get_stylesheet_directory_uri() . \'/assets/css/custom.css\');
    wp_enqueue_script( \'bootstrap-js\', get_template_directory_uri() . \'/assets/lib/bootstrap/dist/js/bootstrap.min.js\');
    wp_enqueue_script( \'imageloaded\', get_template_directory_uri() . \'/assets/lib/imagesloaded/imagesloaded.pkgd.min.js\', array( \'bootstrap-js\' ) );
    wp_enqueue_script( \'tweenmax\', get_template_directory_uri() . \'/assets/lib/gsap/src/minified/TweenMax.min.js\', array(\'imageloaded\') );
    wp_enqueue_script( \'scroll-to-plugin\', get_template_directory_uri() . \'/assets/lib/gsap/src/minified/plugins/ScrollToPlugin.min.js\', array(\'tweenmax\') );
    wp_enqueue_script( \'customToEase\', get_template_directory_uri() . \'/assets/lib/CustomEase.min.js\', array(\'scroll-to-plugin\') );
    wp_enqueue_script( \'configJs\', get_template_directory_uri() . \'/assets/js/config.js\', array(\'customToEase\') );
    wp_enqueue_script( \'zanimation\', get_template_directory_uri() . \'/assets/js/zanimation.js\', array(\'configJs\') );
    wp_enqueue_script( \'corejs\', get_template_directory_uri() . \'/assets/js/core.js\', array(\'zanimation\') );
    wp_enqueue_script( \'mainjs\', get_template_directory_uri() . \'/assets/js/main.js\', array(\'corejs\') );
}   
add_action( \'wp_enqueue_scripts\', \'blogroom\' );

结束

相关推荐

WordPress Plugins won't save

我有一个WordPress网站,我刚刚接管了一个客户,因此我没有能力与以前的网站管理员/开发人员交谈。该网站使用的是YOOtheme对Subway稍加修改的版本。为了更新插件位置,Subway的一部分有“小部件选项”。我无法更改外观或小部件显示的页面,因为我无法保存任何内容。它看起来像已保存,但没有保存,或者您会在保存按钮旁边看到“加载循环”,它一直在运行。Things to note:<WordPress和插件是最新的。在我们转移到新服务器之前,插件是可更新的。新服务器有一个max\\u inpu