我试图制作一个弹出窗口,它将显示帖子标题和帖子缩略图。
我已将此弹出代码添加到类别页面模板中。
基本上,如果您单击帖子标题,弹出窗口将显示帖子缩略图和帖子标题,但是每个弹出窗口都显示相同的帖子详细信息。
我需要进行哪些更改,因此每个弹出窗口都会显示相应的帖子详细信息
例子。我有 3 个帖子,标题为帖子 A、帖子 B、帖子 C,但在灯箱中所有帖子标题都显示为“帖子 A”
任何建议,将不胜感激
这是我使用的代码...........
<div id="maincontainer" style="width:700px; height:auto; display:block;"><!-- Begin Main Container -->
<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
<span id="magblock"> <!-- Begin Post Block -->
<div class="magazinethumbs">
<?php
// check if the post has a Post Thumbnail assigned to it.
if ( has_post_thumbnail() ) {
the_post_thumbnail( 'magazine-thumb' );
}
?>
</div>
<!-- This opens the Lightbox -->
<a class="lbp-inline-link-1 cboxElement" href="#">
<h2 class="indextitle" style="font-size:12px;">
<?php the_title(); ?>
</h2>
</a>
</span> <!-- End Post Block-->
<div style="display: none;"> <!-- Lightbox Popup -->
<div id="lbp-inline-href-1" style="padding:10px; background: #fff;">
<!-- Here is the bug, the lightbox is loading the same post details -->
<div class="magazinethumbs">
<?php
// check if the post has a Post Thumbnail assigned to it.
if ( has_post_thumbnail() ) {
the_post_thumbnail( 'magazine-thumb' );
}
?>
</div>
<h2 class="indextitle" style="font-size:12px;">
<?php the_title(); ?>
</h2>
</div>
</div> <!-- End Lightbox Popup -->
<?php endwhile; else: ?>
<p><?php _e('Sorry, no posts matched your criteria.'); ?></p>
<?php endif; ?>
<?php wp_reset_query();?>
</div><!-- End Main container -->
我正在使用“Lightbox Plus For Wordpress”插件 http://www.endocreative.com/how-to-insert-content-in-a-popup-using-lightbox-plus-for-wordpress/
我尝试了您修改过的代码,但没有用...只需将整个类别页面加载到灯箱内...
这是修改后的代码
<a class="lbp-inline-link-<?php the_ID(); ?> cboxElement" href="#">
<h2 class="indextitle" style="font-size:12px;">
<?php the_title(); ?>
</h2>
</a>
<div style="display: none;"> <!-- begin popup -->
<div id="lbp-inline-href-<?php the_ID(); ?>" style="padding:10px; background: #fff;">
<h2 class="indextitle" style="font-size:12px;">
<?php the_title(); ?>
</h2>
</div>
</div> <!-- End popup -->
谢谢