0

我试图制作一个弹出窗口,它将显示帖子标题和帖子缩略图。

我已将此弹出代码添加到类别页面模板中。

基本上,如果您单击帖子标题,弹出窗口将显示帖子缩略图和帖子标题,但是每个弹出窗口都显示相同的帖子详细信息。

我需要进行哪些更改,因此每个弹出窗口都会显示相应的帖子详细信息

例子。我有 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 -->

谢谢

4

1 回答 1

0

当你回答我的评论时,我可能正在睡觉,所以。

您必须执行该教程的第 2 步,它将为您提供内联灯箱个人设置。

它会给你一个顺序的类

lbp-inline-link-1对于lbp-inline-href-1,

lbp-inline-link-2对于lbp-inline-href-2等等..

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

插入:

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

代替:

<a class="lbp-inline-link-1 cboxElement" href="#">

<a class="lbp-inline-link-<?php echo $i;?>" href="#">

对以下内容执行相同操作:

<div id="lbp-inline-href-1" style="padding:10px; background: #fff;">

<div id="lbp-inline-href-<?php echo $i; ?>" style="padding:10px; background: #fff;">

在结束之前

<?php 
$i++;
endwhile; else: ?>

OBS:您必须将 os 帖子的数量设置为与“内嵌灯箱数量::”相同的数量

例如:如果帖子列表将显示,每页 10 个帖子,在第 2 步“内嵌灯箱数量::”中,您必须设置为 10。

于 2013-11-07T04:23:24.563 回答