好的,这是我的问题。
我已经花了大约 10 个小时来尝试在我的网站上放置一个特色内容滑块。尝试任何我能想到的东西。尝试相同滑块的 3 个不同版本。
网址是:http ://www.heartofphoto.com/slidetest/
但无论如何,这就是我目前要做的:
在标题中,我设法得到了这个:
<script type='text/javascript' src='http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js'></script>
<script type='text/javascript'>try{jQuery.noConflict();}catch(e){};</script>
<script type='text/javascript' src='http://ajax.googleapis.com/ajax/libs/jqueryui/1.7.3/jquery-ui.min.js'></script>
有或没有“无冲突”部分似乎并没有什么不同。而且我相信在我为 Wordpress 安装了“google libary”插件之后,noconflict 部分就出现了。
这是我在页面中应该显示滑块的脚本:
<script type="text/javascript">
jQuery(document).ready(function(){
jQuery("#featured").tabs({fx:{opacity: "toggle"}}).tabs("rotate", 5000, true);
});
</script>
将那个放在我制作的“featured.php”文件中,或者放在顶部包含的 header.php 文件中没有区别。
所以有人知道我做错了什么吗?
一些编辑:我收到错误 SCRIPT438: Object doesn't support this property or method in slidetest,第 139 行字符 3。这是这一行:
jQuery("#featured").tabs({fx:{opacity: "toggle"}}).tabs("rotate", 5000, true);
对于那些想看我的 html 的人。这个版本实际上是使用 php 设置来获取数据:
<div id="featured" >
<ul class="ui-tabs-nav">
<?php
$postcount = 0;
$featured_query = new WP_Query('cat=29');
while ($featured_query->have_posts()) : $featured_query->the_post();
get_the_ID();
$postcount++;
?>
<?php
// get the image filename
$value_feat_img = get_post_custom_values("thumbnail");
if (isset($value_feat_img[0])) { ?>
<li class="ui-tabs-nav-item ui-tabs-selected" id="nav-fragment-<?php echo $postcount; ?>"><a href="#fragment-<?php echo $postcount; ?>">
<img src="<?php echo bloginfo('template_url'); ?>/thumb.php?src=<?php echo get_post_meta($post->ID, "thumbnail", $single = true); ?>&h=50&w=80&zc=1&q=95" alt="<?php the_title(); ?>" /><span><?php the_title(); ?></span></a><?php } ?>
</li>
<?php endwhile; ?>
</ul>
<?php
$postcount = 0;
$featured_query = new WP_Query('cat=29');
while ($featured_query->have_posts()) : $featured_query->the_post();
get_the_ID();
$postcount++;
?>
<!-- Content -->
<div id="fragment-<?php echo $postcount; ?>" class="ui-tabs-panel" style="">
<?php // get the image filename
$value_img = get_post_custom_values("thumbnail");
if (isset($value_img[0])) { ?>
<img src="<?php echo bloginfo('template_url'); ?>/thumb.php?src=<?php echo get_post_meta($post->ID, "thumbnail", $single = true); ?>&h=300&w=390&zc=1&q=95" alt="<?php the_title(); ?>" />
<?php } ?>
<div class="info" >
<h2><a href="<?php the_permalink() ?>" ><?php the_title(); ?></a></h2>
<?php the_excerpt(); ?>
</div>
</div>
<?php endwhile; ?>
</div>