如何在wp中为每个帖子动态或查询这种类型的脚本?
<script>
$(document).ready(function() {
mast.init();
$("#laptop").rollerblade({
imageArray : [
rootPath + 'macbook/front.png',
rootPath + 'macbook/front-side-right.png',
rootPath + 'macbook/side-right.png',
rootPath + 'macbook/back-side-right.png',
rootPath + 'macbook/back.png',
rootPath + 'macbook/back-side-left.png',
rootPath + 'macbook/side-left.png',
rootPath + 'macbook/front-side-left.png'
],
sensitivity : 50,
drag : true
});
});
</script>我需要在wordpress中动态获取rootPath图像。
发布于 2014-09-11 03:48:33
如果你是jQuery和wordpress的新手,首先你需要把你的jQuery引用从$改为jQuery。
接下来,您可以更改主题的header.php以输出根路径
<script>
var rootPath = <?php site_url(); ?>;
</script>现在,如果你真正想要的是你的theme...it的网址,那就稍微改变一下。
<script>
var rootPath = <?php echo get_template_directory_uri(); ?>;
</script>http://codex.wordpress.org/Function_Reference/site_url http://codex.wordpress.org/Function_Reference/get_template_directory_uri
https://stackoverflow.com/questions/25749151
复制相似问题