简体   繁体   English

添加Google图表<script> to Wordpress?

[英]Adding Google Charts <script> to Wordpress?

I'm trying to insert a Google Chart (directly, from HTML, rather than using the Publish option on a Chart from within Sheets. Sheet charts don't do what I need) directly into the WordPress web interface. 我正在尝试将Google图表(直接从HTML而不是从表格中使用图表上的发布选项插入Google图表。表格图表无法满足我的需要)直接插入WordPress网络界面。

Unfortunately, the <script> has to be inserted in head to work. 不幸的是,必须将<script>插入头部才能工作。 Any ideas? 有任何想法吗?

I aim to have a unique chart on every page/post (it's a blog about star mapping, and I'm using a scatter plot as the X/Y star locations), so doing it in a template won't work. 我的目标是在每个页面/帖子上都有一个唯一的图表(这是一个有关星图的博客,并且我使用散点图作为X / Y星位置),因此在模板中执行此操作将无效。

I am not able to understand your whole question properly. 我无法正确理解您的整个问题。 But as you mentioned, you want to add script to head then you can use below code in your theme's functions.php 但是正如您提到的那样,您想要添加脚本到头,然后可以在主题的functions.php中使用以下代码

    function hook_javascript() {
        ?>
            <script>
                alert('Page is loading...');
            </script>
        <?php
    }
    add_action('wp_head', 'hook_javascript');

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM