Wordpress和DD's幻灯片中的终极淡出:代码没有't滚动缩略图
Wordpress and DD's Ultimate Fade-in Slideshow: Code Doesn't Scroll Through Thumbnails
我正在尝试使用Wordpress循环(特定类别(来提取特色图像、链接和摘录,并填充幻灯片JS中的最终淡入淡出。该代码输出正确的格式和语法,并正确显示到这两篇文章的链接。然而,此代码并没有在特色图像中循环。它似乎在同一张图片之间褪色了两次。
目前,这一特定类别中有两个帖子,都以图片为特色。每个帖子都有一段摘录。
所有文档(fadeslideshow.js和jQuery(都在标题中正确链接,在使用Safari的web检查器查看代码时(动态驱动脚本显示透明度发生了变化(,它只是在同一个图像之间切换,所以看起来什么都没发生。
下面的代码在一个单独的.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>
Dynamic Drive的终极渐变幻灯片信息如下:http://www.dynamicdrive.com/dynamicindex14/fadeinslideshow.htm
我的代码在这个网站上:http://johnharvey.hsjjr.net
我还尝试过使用wp_get_attachment_image_src,但没有成功。
我在谷歌、动态硬盘论坛和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仍然不会循环通过,但至少缩略图会循环通过。
相关文章:
- 从桌面读取python文件时高亮显示代码
- 如何将函数包装在函数中以避免代码重复
- 通过单击表单中的按钮,在代码生成中使用javascript生成字母数字代码
- 货币代码为欧元-金额的格式不应包含小数
- Regex代码只允许一个空格
- 如何将屏幕分辨率乘以 80%,然后在代码中使用
- 从var向代码隐藏函数传递值
- 如何动态插入jquery代码
- 如何在php变量中嵌入JQuery代码
- 代码不会验证
- 如何从rails中的代码中删除新行( )
- Angularjs代码未在匿名函数中运行
- 如何做到这一点,使代码在不传递条件后执行函数
- 如何在读取XLS/XLSX本地文件时,使用IE的javascript代码启用未标记为安全的ActiveX控件
- 面向对象的Javascript代码在IE7中不起作用
- 将 jQuery 代码添加到 Index.aspx 页面
- 为什么忽略了eval()代码中的语法错误
- 元素在我的代码中不会.fadeTo.Don'I don’我不知道;s错误的JavaScript、JQuery、H
- 好的,所以我试图弄清楚如何将文本添加到缩略图中(我在下面是一个完整的新手代码)
- Wordpress和DD's幻灯片中的终极淡出:代码没有't滚动缩略图