Javascript Wordpress循环在lightbox中工作不正常?
我正在构建一个带有自定义帖子类型的wordpress公文包。该页面显示了图片的缩略图,当你翻过它们时,你会看到标题、摘录和一个链接,可以在一个灯箱中看到文章的内容。为了得到lightbox,我使用了一个名为lightbox Plus ColorBox的插件。出于某种原因,灯箱在每个posts灯箱中显示最近一篇文章的内容,而不是显示与单击的缩略图相关的内容 该网站的网址是 这是我的页面代码:Javascript Wordpress循环在lightbox中工作不正常?,javascript,jquery,wordpress,lightbox,Javascript,Jquery,Wordpress,Lightbox,我正在构建一个带有自定义帖子类型的wordpress公文包。该页面显示了图片的缩略图,当你翻过它们时,你会看到标题、摘录和一个链接,可以在一个灯箱中看到文章的内容。为了得到lightbox,我使用了一个名为lightbox Plus ColorBox的插件。出于某种原因,灯箱在每个posts灯箱中显示最近一篇文章的内容,而不是显示与单击的缩略图相关的内容 该网站的网址是 这是我的页面代码: <div id="portfolio"> <div class="group"&
<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>
这可能会解决您的问题非常感谢!现在显示的是相关的帖子内容。css样式在第一篇文章中与后续文章略有不同,但我可能可以解决这个问题。非常感谢你的帮助。。很高兴知道:。不要感谢我帮助三个人中的任何一个;jai-ho!!