[英]Wordpress loop not working properly in 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>
替換您的課程和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>
它可能會解決您的問題
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.