![](/img/trans.png)
[英]Making a Slideshow in Wordpress using the Advanced Custom fields plugin and the repeater field
[英]Advanced Custom Field data not showing in Fancybox in Wordpress
我在Wordpress中使用“高級自定義字段”插件將帶有鏈接的圖像(也用於為自定義視頻播放器添加嵌入代碼)輸出到存檔頁面上的帖子中。 自定義字段的輸出代碼放置在div中,該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>
弄清楚了,需要為每個帖子提供一個唯一的ID,因此將開始鏈接的href更改為fancybox中的帖子ID和div ID,並進行了修復!
干杯
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.