【问题标题】:Wordpress functions.php file not workingWordpress functions.php 文件不工作
【发布时间】:2015-11-28 06:56:51
【问题描述】:

我想在function.php中添加我所有的主题JavaScript文件,我的脚本是

<script src="http://localhost/xampp/website/nextgen/wp-content/themes/nextgen/nextgen/js/jquery.min.js"></script> 

如何将这些添加到我的functions.php 我已经尝试了几个教程,但它对我不起作用。

用上面的代码给我演示一下

【问题讨论】:

  • wordpress不会自动加载jquery吗?
  • 是的。您应该注册自己的自定义脚本,并使其依赖于 jquery。查看this answer 了解如何加载依赖项。

标签: javascript php jquery wordpress twitter-bootstrap


【解决方案1】:

把它放在functions.php文件中:

function addthemejs() { 
    wp_enqueue_script( 'myscript', 'http://localhost/xampp/website/nextgen/wp-content/themes/nextgen/nextgen/js/jquery.min.js' , array(), "", false );   );
}

add_action( 'wp_enqueue_scripts' , 'addthemejs' );

我已经硬编码了你的代码,你必须知道这不是一个很好的解决方案,但如果你只是测试它没关系我猜

【讨论】:

    猜你喜欢
    • 2015-02-05
    • 1970-01-01
    • 2014-10-26
    • 2019-05-27
    • 2015-02-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多