简体   繁体   中英

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:

<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'); ?> isn't printing. I'm guessing it's because it's within a while loop that is within another while loop.

Right now that php statement doesn't even print out so the output of that line looks like this:

<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 . Also on line 17, I call that statement prior to above and it prints fine: <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.

How can I get <?php the_sub_field('project_name'); ?> <?php the_sub_field('project_name'); ?> to print out?

<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>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM