Lightbox 仅显示 Wordpress 中当前 post 的数据

Lighbox only showing data of the current post in Wordpress

我想通过使用短代码来展示灯箱的一些功能。除了灯箱中显示的数据外,代码工作正常。它只显示循环中最新的 post 的数据。我怎样才能让灯箱显示属于 post 的数据?

<?php
    // Posts are found
    if ( $posts->have_posts() ) {
        while ( $posts->have_posts() ) :
            $posts->the_post();
            global $post;
            ?>
            <center>
            <div id="su-post-<?php the_ID(); ?>" class="su-post">
                <?php if ( has_post_thumbnail() ) : ?>
                    <a class="su-post-thumbnail" href="<?php the_permalink(); ?>"><?php the_post_thumbnail(); ?></a>
                <?php endif; ?>
                <div class="su-post-excerpt">

                    <!-- Shows the button and the hidden lightbox -->
                    <?php echo do_shortcode ('[su_lightbox type="inline" src="#showInfo"][su_button] Info[/su_button][/su_lightbox]'); ?>
                    <!-- Shows the lightbox if button is clicked with the data -->
                    <?php echo do_shortcode ('[su_lightbox_content id="showInfo"][su_meta key="info" default="Geen tekst"][/su_lightbox_content]'); ?>

                    <?php echo do_shortcode ('[su_lightbox type="inline" src="#showVideo"][su_button] Video[/su_button][/su_lightbox]'); ?>
                    <?php echo do_shortcode ('[su_lightbox_content id="showVideo"][su_video url="{su_meta key=video}"][/su_lightbox_content]'); ?>

                    <?php echo do_shortcode ('[su_lightbox type="inline" src="#showFoto"][su_button] Foto[/su_button][/su_lightbox]'); ?>
                    <?php echo do_shortcode ('[su_lightbox_content id="showFoto"][su_meta key="fotos" default="Geen fotos"][/su_lightbox_content]'); ?>

                </div>
            </div>

            </center>
            <?php
        endwhile;  echo do_shortcode ('[su_lightbox_content id="showInfo"][su_meta key="info" default="Geen tekst"][/su_lightbox_content]'); 
    }
    // Posts not found
    else {
        echo '<h4>' . __( 'Posts not found', 'shortcodes-ultimate' ) . '</h4>';
    }
?>

通过在 while 循环中添加一个计数器并在简码 SRC 和 ID 字段中使用变量。我需要每个 post.

的唯一 ID
$n = 0;  /* Outside While Loop */

echo do_shortcode( '[su_lightbox type="inline" src="#showInfo'.$n.'"][su_button] Info[/su_button][/su_lightbox] ');
echo do_shortcode( '[su_lightbox_content id="showInfo'.$n.'"][su_meta key="info" default="Geen tekst"][/su_lightbox_content]' );

$n++;   /* Inside While Loop */