[英]php statement isn't printing out. It's in a while loop that is within another while loop
On line 36 below, I have this line: 在下面的第36行,我有这行:
<li>
<a class="fancybox" rel="<?php the_sub_field('project_name'); ?>-gallery" href="<?php the_sub_field('still'); ?>">
<img src="<?php the_sub_field('still'); ?>" alt="<?php the_sub_field('project_name'); ?>-still" height="71" width="100"></a>
</li>
I'm not sure why but <?php the_sub_field('project_name'); ?>
我不确定为什么,但是<?php the_sub_field('project_name'); ?>
<?php the_sub_field('project_name'); ?>
isn't printing. <?php the_sub_field('project_name'); ?>
不打印。 I'm guessing it's because it's within a while
loop that is within another while
loop. 我猜是因为它在while
循环内,而在while
循环内。
Right now that php statement doesn't even print out so the output of that line looks like this: 现在,该php语句甚至没有打印出来,因此该行的输出如下所示:
<a class="fancybox" rel="-gallery" href="http://localhost/wordpress/wp-content/uploads/2014/12/17.jpg"><img src="http://localhost/wordpress/wp-content/uploads/2014/12/17.jpg" alt="-still" height="71" width="100"></a>
Notice there is nothing before -gallery
and -still
. 注意, -gallery
和-still
之前没有任何-still
。 Also on line 17, I call that statement prior to above and it prints fine: <div id="<?php the_sub_field('project_name'); ?>">
. 同样在第17行,我在上面的代码之前调用了该语句,它可以正常打印: <div id="<?php the_sub_field('project_name'); ?>">
。 So that's why I'm guessing it has something to do with the fact that a while
loop is within another while
loop. 因此,这就是我猜测它与while
循环位于另一个while
循环内的事实有关的原因。
How can I get <?php the_sub_field('project_name'); ?>
我怎么能得到<?php the_sub_field('project_name'); ?>
<?php the_sub_field('project_name'); ?>
to print out? <?php the_sub_field('project_name'); ?>
打印出来?
<div id="tabs">
<?php if(have_rows('project')): ?>
<ul>
<?php while( have_rows('project') ): the_row(); ?>
<li><a href="#<?php the_sub_field('project_name'); ?>"><?php the_sub_field('project_name'); ?></a></li>
<?php endwhile; ?>
</ul>
<?php while( have_rows('project') ): the_row(); ?>
<div id="<?php the_sub_field('project_name'); ?>">
<img class="project-background" src="<?php the_sub_field('background_image'); ?>" alt="<?php the_sub_field('project_name'); ?>-background" height="530" width="325">
<div class="project-trailer">
<iframe src="//player.vimeo.com/video/<?php the_sub_field('vimeo_id'); ?>?title=0&byline=0&portrait=0&color=ffffff" width="750" height="300" frameborder="0" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe>
</div>
<div class="project-stills">
<h3>Stills</h3>
<?php
// check if the repeater field has rows of data
if( have_rows('stills') ):
// loop through the rows of data
while ( have_rows('stills') ) : the_row(); ?>
<li><a class="fancybox" rel="<?php the_sub_field('project_name'); ?>-gallery" href="<?php the_sub_field('still'); ?>"><img src="<?php the_sub_field('still'); ?>" alt="still" height="71" width="100"></a></li>
<?php endwhile;
else :
// no rows found
endif; ?>
</div>
</div>
<?php endwhile; ?>
<?php endif; ?>
</div>
<li>
<a class="fancybox" rel="<?php echo the_sub_field('project_name'); ?>-gallery" href="<?php echo the_sub_field('still'); ?>">
<img src="<?php echo the_sub_field('still'); ?>" alt="<?php echo the_sub_field('project_name'); ?>-still" height="71" width="100"></a>
</li>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.