[英]How to create a seperate popup form for each wordpress post on-click
我已經通過具有一些自定義字段的自定義帖子類型插件列出了我的數據。 下面的代碼將顯示自定義帖子類型列表數據。
<?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 鏈接的數據...等。
我正在嘗試通過 popup-maker 插件創建一個彈出窗口,它創建了一個類來打開一個彈出窗口。 當我把那個類放在上面的代碼中時(請參閱下文),在這種情況下,每個帖子只會應用一個彈出窗口。
<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; ?>
請注意,您可能還需要在目標設置中的該頁面上出現一些彈出窗口,否則它們可能無法初始化。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.