【问题标题】:Can't add javascript to divi footer in wordpress无法将javascript添加到wordpress中的divi页脚
【发布时间】:2022-01-17 21:33:06
【问题描述】:

我正在使用 divi 主题,并且在 footer.php 中运行了一行简单的 javascript:

<script>
    console.log("inside of footer.php");
</script>

然后,我使用 Divi Theme Builder 制作自定义页脚,发现 footer.php 不再运行。我需要将 javascript 添加回页脚,但不知道要在哪个文件中输入它。如何将 javascript 放入页脚?

【问题讨论】:

    标签: wordpress wordpress-theming custom-wordpress-pages divi


    【解决方案1】:

    完全不建议在外部主题中编辑footer.php模板。

    我们使用它的方式是。

    1. 转到your_page/wp-content/themes/active_theme_name

    2. 创建一个 custom.js

    3. 然后在functions.php中加入这一行:

    wp_enqueue_script( 'customjs', get_template_directory_uri() . '/custom.js', array ( 'jquery' ), 1.1, true);

    阅读,现在您可以在 custom.js 文件中写入您的 console.log("inside of footer.php");

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-03-25
      • 2017-05-14
      • 1970-01-01
      • 1970-01-01
      • 2019-08-04
      • 1970-01-01
      • 1970-01-01
      • 2021-03-22
      相关资源
      最近更新 更多