如何在WordPress中添加外部JavaScript代码?

2026-04-01 04:041阅读0评论SEO教程
  • 内容介绍
  • 文章标签
  • 相关推荐

本文共计342个文字,预计阅读时间需要2分钟。

如何在WordPress中添加外部JavaScript代码?

我想在WordPress中插入外部JavaScript到指定文件中。如果使用脚本标记包含它,则显示下面是我的代码global$wpdb; include(assetphpch+我想在WordPress中插入外部JavaScript到指定文件中的外部Javascript。

我想在WordPress中插入放置在该文件夹中的外部JavaScript.如果我使用脚本标记包含它显示“下面是我的代码global$wpdb;include(assetphpch

我想在WordPress中插入放置在该文件夹中的外部Javascript.

如果我使用脚本标记包含它显示“

下面是我的代码

global $wpdb;

include("/asset/php/chart4php/inc/chartphp_dist.php");

$p new chartphp();

$p->data_sql $wpdb->get_results("select t2.name, count(t1.id) as score from custom_status as t2 left join wpsp_ticket as t1 on t2.name t1.status group by t2.name");

$p->chart_type "bar";

// Common Options

$p->title "Category Sales";

$p->xlabel "Category";

$p->ylabel "Sales";

$color array("#1AAF5D","#F2C500","#F45B00","#8E0000","#0E948C");

$p->color $color[rand(0,4)];

$out $p->render(c1);

尝试包括js文件

wp_enqueue_script( jquery );

wp_enqueue_script( ajax_search );

wp_register_script( chartphp, plugins_url(/asset/php/chart4php/chartphp.js, __FILE__), array(jquery));

wp_enqueue_script(‘chartphp’);

另外我想要包含3个移动文件

解决方法:

如何在WordPress中添加外部JavaScript代码?

在WordPress中包含脚本的正确方法是使用wp_enqueue_script().

如果您以前注册过脚本,则只需引用它

You could either link a script with a handle previously registered using the 07001 function, or provide this function with all the parameters necessary to link a script.

请注意,如果在dependencies参数中包含jQuery等默认脚本,则无需单独注册和/或将它们排入队列.

标签jquery,wordpress,php,Javascript,charts

来源 codeday.me/bug/20190627/1308258.html

本文共计342个文字,预计阅读时间需要2分钟。

如何在WordPress中添加外部JavaScript代码?

我想在WordPress中插入外部JavaScript到指定文件中。如果使用脚本标记包含它,则显示下面是我的代码global$wpdb; include(assetphpch+我想在WordPress中插入外部JavaScript到指定文件中的外部Javascript。

我想在WordPress中插入放置在该文件夹中的外部JavaScript.如果我使用脚本标记包含它显示“下面是我的代码global$wpdb;include(assetphpch

我想在WordPress中插入放置在该文件夹中的外部Javascript.

如果我使用脚本标记包含它显示“

下面是我的代码

global $wpdb;

include("/asset/php/chart4php/inc/chartphp_dist.php");

$p new chartphp();

$p->data_sql $wpdb->get_results("select t2.name, count(t1.id) as score from custom_status as t2 left join wpsp_ticket as t1 on t2.name t1.status group by t2.name");

$p->chart_type "bar";

// Common Options

$p->title "Category Sales";

$p->xlabel "Category";

$p->ylabel "Sales";

$color array("#1AAF5D","#F2C500","#F45B00","#8E0000","#0E948C");

$p->color $color[rand(0,4)];

$out $p->render(c1);

尝试包括js文件

wp_enqueue_script( jquery );

wp_enqueue_script( ajax_search );

wp_register_script( chartphp, plugins_url(/asset/php/chart4php/chartphp.js, __FILE__), array(jquery));

wp_enqueue_script(‘chartphp’);

另外我想要包含3个移动文件

解决方法:

如何在WordPress中添加外部JavaScript代码?

在WordPress中包含脚本的正确方法是使用wp_enqueue_script().

如果您以前注册过脚本,则只需引用它

You could either link a script with a handle previously registered using the 07001 function, or provide this function with all the parameters necessary to link a script.

请注意,如果在dependencies参数中包含jQuery等默认脚本,则无需单独注册和/或将它们排入队列.

标签jquery,wordpress,php,Javascript,charts

来源 codeday.me/bug/20190627/1308258.html