如何在点击时为每个wordpress帖子创建一个单独的弹出表单



我通过一个具有一些自定义字段的自定义post类型插件列出了我的数据。下面的代码将显示自定义帖子类型的列表数据。

<?php 
$args = array(
'post_type'   => 'inde_case',
'posts_per_page' => -1
);
query_posts($args);
?>
<ul class="case_study_section1 col-md-12 nopadding">
<?php while ( have_posts() ) : the_post(); ?>
<?php $terms = get_the_terms( get_the_ID(), 'inde_case_category');
if( !empty($terms) ) {
$term = array_pop($terms);
} 
?>
<li data-category="<?php echo $term->slug; ?>" class="case_study_img col-md-3 col-sm-6">
<div class="caseSection">
<div class="imagediv"><?php the_post_thumbnail(); ?></div>
<div style="width:100%;float:left;">
<a class="case_study_pdf"   href="<?php the_field('linkicon'); ?>" >PDF</a>
<a class="case_study_title"  href="<?php the_field('linktext'); ?>" ><?php the_title(); ?></a>
</div>
</div>
</li>
<?php endwhile; ?>

我已经正确地列出了我的数据,有缩略图和pdf链接。。。等

我正在尝试创建一个弹出式制作插件,它已经创建了一个类来打开一个弹出窗口。当我把这个类放在上面的代码中时(参考下面(,在这种情况下,每个帖子只有一个弹出窗口。

<a class="popmake-6981 case_study_pdf"   href="<?php the_field('linkicon'); ?>" >PDF</a>

当有人点击pdf链接时,我如何为每个特定的帖子打开一个单独的弹出窗口?或者我可以使用postId或一些唯一的数据打开一个特定的弹出表单吗?请忠告。

您可以创建带有[popup]短代码的弹出窗口,如下所述。匹配ID和触发器类。

<?php while ( have_posts() ) : the_post();?>
<article>
<h2><a class="popmake-post-<?php the_ID();?>" href="<?php the_permalink();?>"><?php the_title();?></a></h2>
<?php echo do_shortcode("[popup id='post-". get_the_ID() ."' size='small' title='". get_the_title() ."']". get_the_content() . "[/popup]");?>
</article>
<?php endwhile; ?>

注意,在目标设置中,您可能还需要在该页面上弹出一些窗口,否则它们可能无法初始化。

最新更新