Javascript Wordpress和DD';s终极淡入幻灯片:代码不';不要浏览缩略图

Javascript Wordpress和DD';s终极淡入幻灯片:代码不';不要浏览缩略图,javascript,jquery,slideshow,wordpress,Javascript,Jquery,Slideshow,Wordpress,我正在尝试使用Wordpress循环(特定类别)来获取特色图片、链接和摘录,并填充最终的淡入式幻灯片。代码输出正确的格式、语法,并正确显示两篇文章的链接。然而,这段代码并没有在特色图片中循环。它似乎在同一个图像之间消失了两次 目前在这一特定类别中有两篇文章,都以图片为特色。每篇文章都有摘录 所有文档(fadeslideshow.js和jQuery)都在标题中正确链接,并且在使用Safari的web inspector查看代码时-动态驱动脚本显示透明度的变化-它只是在同一图像之间切换,因此看起来什

我正在尝试使用Wordpress循环(特定类别)来获取特色图片、链接和摘录,并填充最终的淡入式幻灯片。代码输出正确的格式、语法,并正确显示两篇文章的链接。然而,这段代码并没有在特色图片中循环。它似乎在同一个图像之间消失了两次

目前在这一特定类别中有两篇文章,都以图片为特色。每篇文章都有摘录

所有文档(fadeslideshow.js和jQuery)都在标题中正确链接,并且在使用Safari的web inspector查看代码时-动态驱动脚本显示透明度的变化-它只是在同一图像之间切换,因此看起来什么都没有发生

下面的代码位于单独的.php文档中,该文档在标题中调用

<script type="text/javascript">
<?php query_posts('cat=7'); ?> //queries posts only from featured category
<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>

var mygallery=new fadeSlideShow({ 
wrapperid: "fadeshow", //ID of blank DIV on page to house Slideshow
dimensions: [585, 350], //width/height of gallery in pixels. Should reflect dimensions of largest image
imagearray: [

<?php   $thumbnails = get_posts('posts_per_page=5'); //adding category=7 here breaks code
        $my_excerpt = get_the_excerpt();
        $url = wp_get_attachment_url( get_post_thumbnail_id($post->ID) ); 
        $total = count($thumbnails); //this is to count the number of thumbnails in foreach loop to NOT add a comma to the last one
        $i=1;

        foreach ($thumbnails as $thumbnail) {
        if ( has_post_thumbnail($thumbnail->ID)) {
        $i++;

         echo '["'.$url.'","'.get_permalink( $thumbnail->ID ).'","","'.$my_excerpt.'"]'; //This spits out the exact correct code
         if ($i != $total) { echo', '; }//this is to count the number of thumbnails in foreach loop to NOT add a comma to the last one

 }} ?>
],

displaymode: {type:'auto', pause:3000, cycles:0, wraparound:false},
persist: false, //remember last viewed slide and recall within same session?
fadeduration: 500, //transition duration (milliseconds)
descreveal: "ondemand",
togglerid: ""
})

<?php endwhile; endif; ?> //This ends the wordpress loop
<?php wp_reset_query(); ?>

</script>

//仅从特色类别查询帖子
var mygallery=新的fadeSlideShow({
wrapperid:“fadeshow”//PageToHouse幻灯片上空白DIV的ID
尺寸:[585350],//画廊的宽度/高度(像素)。应反映最大图像的尺寸
图像阵列:[
],
显示模式:{type:'auto',pause:3000,cycles:0,wrapparound:false},
persist:false,//还记得上次在同一个会话中查看的幻灯片和回忆吗?
fadeduration:500,//转换持续时间(毫秒)
描述:“ondemand”,
togglerid:“
})
//这就结束了wordpress循环
Dynamic Drive的最终淡入式幻灯片放映信息如下:

我的代码在此网站上:

我也尝试过使用wp\u get\u attachment\u image\u src,但没有成功

我在Google、Dynamic Drive论坛和Wordpress Codex上进行了彻底的搜索,没有找到任何可以尝试的东西。我相信,也许我没有足够的信息了解什么是错误的,不知道还有什么需要寻找。我相信有一个相当简单的解决办法,我只是没有经验知道出了什么问题


非常感谢你们的帮助和知识

我不完全清楚为什么会这样——但我解决了这个问题。我没有在foreach循环上定义变量,而是将其向下移动到循环中:

<?php   $thumbnails = get_posts('posts_per_page=5'); //adding category=7 here breaks code

        $total = count($thumbnails); //this is to count the number of thumbnails in foreach loop to NOT add a comma to the last one
        $i=1;

        foreach ($thumbnails as $thumbnail) {
        if ( has_post_thumbnail($thumbnail->ID)) {
        $i++;



         echo '["'.wp_get_attachment_url( get_post_thumbnail_id($thumbnail->ID) ).'","'.get_permalink( $thumbnail->ID ).'","","'.get_the_excerpt($thumbnail->ID).'"]'; //This spits out the exact correct code
         if ($i != $total) { echo', '; }//this is to count the number of thumbnails in foreach loop to NOT add a comma to the last one


 }

}
?>


except仍然没有循环,但至少缩略图可以循环。

其他注意事项-我注意到向下移动脚本标记(例如在wordpress循环下方)或向下移动wordpress循环(就在定义变量之前)会中断整个代码-没有图像显示。它似乎在链接之间正确循环。但是,它不会循环浏览图像(在WP post中设置为特色图像)或WP摘录…不完全确定为什么会这样做-但我解决了这个问题。我没有在foreach循环上定义变量,而是将其向下移动到循环中: