我已将此脚本编写在scripts.js 文件中。我只想为主页执行前半部分,为自定义帖子类型页面执行后半部分。我怎样才能在 WordPress 中做到这一点?
// This Chunk For Home Page [Part one]
jQuery("#front-page-slider").responsiveSlides({
maxwidth: 390,
"auto": true,
"pager": false,
"nav": false,
"pause": true,
speed: 800
});
// This Chunk is for For Only Custom Post Page [Part Two]
$("a[rel^='prettyPhoto']").prettyPhoto({animation_speed:'normal',theme:'pp_default',slideshow:3000, autoplay_slideshow: false});
var width = $(window).width();
最佳答案
正如评论中所建议的,您可以利用 body 类,例如:
if(jQuery('body.home').length){alert('home');}
关于javascript - 在一个js文件中为不同的wordpress页面添加多个自定义脚本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27319508/