我正在使用自定义元数据将图像显示为 wordpress 中的帖子。当我单击主页上的图像时,它会在颜色框中打开,这是完美的。
发生了什么:现在,将图像加载到颜色框中,当我单击图像时,它会循环浏览我主页上的图像(不是我想要的)。
我希望发生的事情:将图像加载到颜色框中,当我单击它时,它将充当链接并将帖子(与该图像相关联)加载到颜色框中。
我不清楚如何做到这一点。我用来显示帖子图像元数据的代码是:
<?php
// check for spine image
$spine = get_post_meta($post->ID, 'spine image', $single = true);
// check for spine class
$spine_class = get_post_meta($post->ID, 'spine class', $single = true);
?>
<div style=" #position: center; #left: 50%; height: 650px; display: table-cell; vertical-align: middle;">
<div class="post" id="post-<?php the_ID(); ?>">
<div class="entry">
<?php
// If there is a spine image, display it as the post
if($spine !== '') { ?>
<p>
<a rel="bookmark" href="<?php echo $spine; ?>" title="<?php the_title_attribute(); ?>">
<img src="<?php echo $spine; ?>" class="<?php if($spine_class !== '') { echo $spine_class; } else { echo "left"; } ?>"
height="400" onMouseOver='resizeImg(this, 150)' onMouseOut='resizeImg(this)'
/>
</a>
</p>
<?php } // end if statement
// if there's not a spine image
else { echo ''; }
?>
</div>
</div>
</div>
我用于颜色框的功能是:
<script type="text/javascript">
$(document).ready(function(){
//Examples of how to assign the ColorBox event to elements
$("a[rel='bookmark']").colorbox({transition:"fade"});
});
</script>
这样带有“书签”属性的链接将在颜色框中打开。现在我怎样才能使颜色框中的图像链接到相关网页(或充当任何网页的链接......一次一步)?
我希望这是有道理的,谢谢你的帮助,mlord