繁体   English   中英

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

[英]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.

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