我正在尝试在wordpress网站上使用fancybox构建一个库。这些图库项目是高级自定义字段(ACFS)中继器。
问题是,客户端只想要一些图库项目作为链接,因为有些图库只是带有文本的彩色框,因此,不应该是链接,不应该在fancybox中打开。
正如您在下面的代码中看到的那样,我调用转发器中的所有行,并将它们放在自己的div中,并使用hrefs。
如何检测行是图像还是文本框,并相应地添加href?
int p = 4;
int i;
int id[5] = {1,2,3,4,5};
for(i=p; i!=id[i]; i=id[i]) {
printf("Loop executed!\n");
}
在这里查看问题,"我们的工作":www.entirecreative.com/stone
答案 0 :(得分:0)
您可以使用get_sub_field()
检索字段的值(而不是使用the_sub_field()
回显它)。如果未设置该值,则它将返回false
,因此如果“p3projectreshires”子字段为if
,则可以在A
语句中使用它仅输出<?php
if( have_rows('p3projectsres') ):
while ( have_rows('p3projectsres') ) : the_row(); ?>
<div class="s3block"><p>
<!--
check to see if there is a value for "p3projectreshires"
and if there is open the A tag
-->
<?php if ( get_sub_field('p3projectreshires') ) : ?>
<a href="<?php the_sub_field('p3projectreshires'); ?>" rel="lightbox" title="<?php the_sub_field('p3projectresdescription'); ?>">
<?php endif; ?>
<div class="s3blockblurb">
<div class="scribe7">
<?php the_sub_field('p3projectresblurb'); ?>
</div>
<div class="s3blockfaded"><?php the_sub_field('p3projectreslocation'); ?></div>
</div>
<!-- Only include the preview image if it is set -->
<?php if ( get_sub_field('p3projectrespreview') ) : ?>
<img src="<?php the_sub_field('p3projectrespreview'); ?>" />
<?php endif; ?>
<!--
check to see if there is a value for "p3projectreshires"
and if there is close the A tag
-->
<?php if ( get_sub_field('p3projectreshires') ) : ?>
</a>
<?php endif; ?>
</p></div>
<?php endwhile;
else : endif;
?>
打开/关闭标记设置在转发器行上。您还可以通过选中“p3projectreshires”来有条件地包含预览图像。
{{1}}