Wordpress循环在灯箱中无法正常工作?

时间:2014-02-11 09:09:08

标签: javascript jquery wordpress lightbox

我正在使用自定义帖子类型构建wordpress组合。该页面显示图像的缩略图,当您滚动它们时,您会看到标题,摘录和链接,以查看灯箱中帖子的内容。为了获得灯箱,我使用了一个名为Lightbox Plus ColorBox的插件。出于某种原因,灯箱会显示每个帖子灯箱中最新帖子的内容,而不是显示与点击的缩略图相关的内容。

网站网址为http://www.ginahughes.co.uk

这是我的网页代码:

<div id="portfolio">   

<div class="group">  

<?php if (have_posts()) : while (have_posts()) : the_post(); ?>  

    <?php  
        $title= str_ireplace('"', '', trim(get_the_title()));  
        $desc= str_ireplace('"', '', trim(get_the_content())); 

    ?>     


            <div class="bp-wrapper">  
                <a title="<?=$title?>: <?=$desc?>" href="<?php the_permalink() ?>"><?php the_post_thumbnail('portfolio-thumb'); ?></a>

                  <div class="bp-post-details">
                      <a title="<?=$title?>: <?=$desc?>" rel="lightbox" href="<?php the_permalink() ?>">
                      <h4>
                          <a class="lbp-inline-link-1 cboxElement" href="#">
                              <?=$title?></a></strong></h4>
                      <p><?php print get_the_excerpt(); ?></p>
                      </a>



                  </div>

            </div> 
             <div style="display: none;">
            <div id="lbp-inline-href-1" style="padding:10px; ">
                <?php the_content(); ?>
            </div>
        </div> 








<?php endwhile; endif; wp_reset_query(); ?>

</div>  

</div>  

1 个答案:

答案 0 :(得分:0)

将您的类和ID替换为动态类似

<div id="portfolio">   

<div class="group">  

    <?php 
$i=1;
if (have_posts()) : while (have_posts()) : the_post(); ?>  

    <?php  
        $title= str_ireplace('"', '', trim(get_the_title()));  
        $desc= str_ireplace('"', '', trim(get_the_content())); 

    ?>     


            <div class="bp-wrapper">  
                <a title="<?=$title?>: <?=$desc?>" href="<?php the_permalink() ?>"><?php the_post_thumbnail('portfolio-thumb'); ?></a>

                  <div class="bp-post-details">
                      <a title="<?=$title?>: <?=$desc?>" rel="lightbox" href="<?php the_permalink() ?>">
                      <h4>
                          <a class="lbp-inline-link-<?=$i?> cboxElement" href="#">
                              <?=$title?></a></strong></h4>
                      <p><?php print get_the_excerpt(); ?></p>
                      </a>



                  </div>

            </div> 
             <div style="display: none;">
            <div id="lbp-inline-href-<?=$i?>" style="padding:10px; ">
                <?php the_content(); ?>
            </div>
        </div> 








<?php $i++;endwhile; endif; wp_reset_query(); ?>

</div>  

</div> 

它可以解决你的问题

相关问题