【发布时间】:2017-01-24 11:57:24
【问题描述】:
尝试了几种方法,但都没有奏效,也不知道还能做什么。作为团队页面的一部分,我有一个带有 4 个子字段的转发器字段——图像、标题(标题)、链接(触发模式)和详细信息(模式文本内容)——其中一些应该在单击时打开一个带有额外信息的模式。模式工作正常,但是当我尝试在代码中插入一个计数器以打开每个团队成员的相应子字段时,它停止工作并且什么都没有打开。
这是一段代码。非常感谢任何帮助。
<div class="team-block w4 clear" >
<?php
if( have_rows('team_member') ):
$counter = 1;
?>
<ul>
<?php
while( have_rows('team_member') ): the_row();
// vars
$image = get_sub_field('team_member_image');
$title = get_sub_field('team_member_title');
$link = get_sub_field('link_to_details');
$details = get_sub_field('team_member_details');
?>
<li class="team-member-box">
<?php if( $link ): ?>
<a href="<?php echo $link; ?>">
<?php endif; ?>
<img class="team-member-image" src="<?php echo $image['url']; ?>" alt="<?php echo $image['alt'] ?>" />
<?php
echo $title;
if( $link ):
?>
</a>
<?php
endif;
if( $link ):
?>
<div class="remodal team-member-details" data-remodal-id="modal<?php echo $counter;?>">
<button data-remodal-action="close" class="remodal-close"></button>
<h3>Qualifications</h3>
<p><?php echo $details; ?></p>
</div>
<?php endif; ?>
</li>
<?php
$counter++;
endwhile;
?>
</ul>
<?php endif; ?>
</div>
【问题讨论】:
标签: php wordpress repeater advanced-custom-fields