PHP 语句未打印出来.它在一个 while 循环中,在另一个 while 循环中


php statement isn't printing out. It's in a while loop that is within another while loop

在下面的第 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>

我不知道为什么,但<?php the_sub_field('project_name'); ?>没有打印。我猜这是因为它在另一个while循环中的while循环中。

现在,该

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>

请注意,在-gallery-still之前没有任何内容。同样在第 17 行,我在上面之前调用该语句,它打印得很好:<div id="<?php the_sub_field('project_name'); ?>"> .所以这就是为什么我猜这与一个while循环在另一个while循环中的事实有关。

如何让<?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&amp;byline=0&amp;portrait=0&amp;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>