简体   繁体   中英

How to create a seperate popup form for each wordpress post on-click

I have listed my data through a custom-post-type plugin having some custom fields. Below code will display the custom-post-type listing data.

    <?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; ?>

I have properly listed my data having thumbnail and pdf link...etc.

I am trying to create a popup by popup-maker plugin, it has created a class to open a popup. And when I put that class in above code (refer below), in this case only one popup will apply for each post.

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

When somebody click on pdf link how can I open a separate popup for each particular post? Or can I open a specific popup-form using postId or some unique data? Please Advice.

You can create popups with their [popup] shortcodes, like described here . Match ID and a trigger class.

<?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; ?>

Beware that you may also need some popup on that page in targeting settings, otherwise they may not initialize.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM