我使用Wordpress中的高级自定义字段插件输出带有链接的图像(也用于为自定义视频播放器添加嵌入代码)到存档页面上的帖子中。自定义字段的输出代码放在隐藏的div中,然后在单击.watchsession链接时在fancybox中加载。问题是,ACF内容在调用时不会加载到fancybox中。如果我将代码放在它显示的隐藏div之外。不知道我哪里出错了。代码如下!
干杯,
<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
<a id="fancybox-button" href="#fancybox-content" class="watchsession" title="<?php the_title(); ?>">Watch</a>
<div style="display: none;">
<div id="fancybox-content" style="width:600px; height:400px;overflow: hidden;">
<img src="<?php the_field('upload_screenshot'); ?>"/>
</div>
</div>
</article>
<script type="text/javascript">
( function($) {
$(document).ready(function() {
$("#fancybox-button").fancybox({
helpers : {
title : {
type: 'inside',
position : 'top'
}
},
'transitionIn' : 'elastic',
'transitionOut' : 'elastic',
});
});
} ) ( jQuery );
</script>
答案 0 :(得分:0)
想出来,需要为每个帖子提供一个唯一的ID,所以将打开链接的href更改为fancybox中的post id和div id并修复它!
干杯