在body类中,还应该找到与页面id相对应的类
(即。<body class=".. page-id-161"
>;)在这种情况下,您可以修改脚本:
(function($) {
//create array of classes for pages where to exclude the .wppr-review-container from being moved
var toExclude=[\'page-id-161\',\'page-id-162\',\'page-id-163\'];
// get all the <body> classes
var elementClasses = jQuery("body").attr("class").split(" ");
jQuery(document).ready(function() {
for(var i = 0; i < elementClasses.length; i++) {
// run only if the current page has class single ( per your script) AND IS NOT among the array toExclude
if($(\'body\').hasClass(\'single\') && jQuery.inArray(elementClasses[i], toExclude) ===-1) {
var wppr = jQuery(\'.wppr-review-container\'),
ed_tags = jQuery(\'.expand-divi-below-tags\');
if ( wppr.length && ed_tags.length ) {
wppr.insertBefore(ed_tags);
}
}
}
});
})(jQuery);