【发布时间】:2016-05-04 22:31:05
【问题描述】:
由于某种原因,我用 wordpress 制作的模板的正常 src 路径不起作用。它嵌入在连接到我的footer.php 的javascript 中。现在我的问题是:是否可以在带有 php sn-p 的 javascript 中调用带有 src 的图像? 到目前为止,这是我的代码:
var d = new Date();
document.getElementById("copyright").innerHTML = "©" + " " + (d.getFullYear()) + " " + "All Rights Reserved" + " " + " " +"<img src='wp-content/themes/wpboot/images/maple.svg' alt='Canadian maple leaf' width='14'>" + " " + "We Are A Canadian Company";
我正在尝试添加这样的 php sn-p:
<img src="<?php bloginfo('template_directory'); ?>/images/maple.svg" width="60" alt="Maple">
要实现这样的目标:
document.getElementById("copyright").innerHTML = "©" + " " + (d.getFullYear()) + " " + "All Rights Reserved" + " " + " " +"<img src='<?php bloginfo('template_directory'); ?>/images/maple.svg' alt='Canadian maple leaf' width='14'>" + " " + "We Are A Canadian Company";
我尝试构建一个名为:
var template = "<?php bloginfo('template_directory'); ?>/";
我添加到 src 但我没有工作.. 任何线索?
【问题讨论】:
-
你必须在女巫文件中使用..?像外部 js 或 .. 默认 WP 文件?
-
wordpress文件夹内的外部js
-
给我 js 处理程序,例如 'wp_enqueue_script('ajax-script', plugins_url('/js/myjquery.js', FILE), array('jquery')) ;' “ajax-script”是处理程序
标签: javascript php wordpress src