【问题标题】:can't add custom js files to wpbootstrap无法将自定义 js 文件添加到 wpbootstrap
【发布时间】:2023-03-12 15:47:01
【问题描述】:

https://github.com/320press/wordpress-bootstrap

如何将 custom.js 添加到这个主题?我不太擅长 gruntjs。假设它的路径是library/js/custom.js

这里是 gruntfile:https://github.com/320press/wordpress-bootstrap/blob/master/Gruntfile.js

谢谢!

【问题讨论】:

    标签: wordpress twitter-bootstrap gruntjs


    【解决方案1】:

    您为什么不使用enqueue 将脚本嵌入到您的主题中。在function.php 文件中创建一个函数为

    /**
    *Enqueue styles.
    */
    
    function add_scripts() {
    
    wp_register_script( 'customScript', get_template_directory_uri() . 'library/js/custom.js', array(), '1.0.0', true );
    // here it is just example of path. you can use yours.
    wp_enqueue_script( 'customScript' );
    
    }
    
    add_action( 'wp_enqueue_scripts', 'add_scripts' );
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-12-26
      相关资源
      最近更新 更多