簡體   English   中英

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'); ?> <?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之前沒有任何-still 同樣在第17行,我在上面的代碼之前調用了該語句,它可以正常打印: <div id="<?php the_sub_field('project_name'); ?>"> 因此,這就是我猜測它與while循環位於另一個while循環內的事實有關的原因。

我怎么能得到<?php the_sub_field('project_name'); ?> <?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>

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM