0
場景:我有一個鏈接列表顯示來自帖子類型(視頻)的查詢。有一個CTA可以查看鏈接到YouTube的視頻。WordPress的:查詢帖子在Modal - 顯示標題
更改:當用戶單擊CTA按鈕時,我正在更改功能以執行模式/表單。我想在他們剛剛點擊的模式內顯示視頻/鏈接的標題。我被困在那部分,因爲它只顯示最近的標題。我也喜歡資產url(前一個直接鏈接)在隱藏表單域中填充。
CODE爲視頻
<a name="webinars"></a>
\t \t \t <img class="title-icon" src="<?php bloginfo('stylesheet_directory'); ?>/images/icon_video.png" width="64" height="60" alt="">
\t \t \t <h3>Webinars</h3>
\t \t \t <div class="container container--discover text-center">
\t \t \t \t <div class="row">
\t \t \t \t \t <?php $args = array('post_type' => array('videos'), 'showposts' => 3) ?>
\t \t \t \t \t <?php query_posts($args); ?>
\t \t \t \t \t <?php while (have_posts()) : the_post(); ?>
\t \t \t \t \t \t <div class="asset asset--video col-sm-4">
<a href="#" onclick="ga('send', 'event', 'Video', 'Clicked', '<?php the_title(); ?>');" rel="bookmark" data-reveal-id="formModal"><div class="post" id="post-<?php the_ID(); ?>">
\t \t \t \t \t \t \t \t <div class="thumb <?php if (in_category('enterprise-technology-solutions')) { ?>thumb--yellow<?php } elseif (in_category('digital-solutions')) { ?>thumb--orange<?php } else { ?>thumb--green<?php } ?>"><?php if (has_post_thumbnail()) { the_post_thumbnail("medium"); } \t else { echo '<img src="' . get_bloginfo('stylesheet_directory') . '/images/thumb-default.jpg" />'; } ?></div>
\t \t \t \t \t \t \t \t <h5><?php the_title(); ?></h5>
\t \t \t \t \t \t \t \t <?php the_excerpt(); ?><br>
\t \t \t \t \t \t \t \t <div class="btn btn--black btn--short">View Now</div>
\t \t \t \t \t \t \t </div></a>
\t \t \t \t \t \t </div>
\t \t \t \t \t <?php endwhile; ?>
\t \t \t \t </div>
碼查詢模態
<div id="formModal" class="reveal-modal">
\t <div class="contact-form">
\t \t <?php $args = array('post_type' => array('videos'), 'showposts' => 1) ?>
\t \t <?php query_posts($args); ?>
\t \t <?php while (have_posts()) : the_post(); ?>
\t
\t \t <h3><?php the_title(); ?></h3>
\t \t <form action="...">
<input id="field0" name="firstName" type="text" required pattern="[a-zA-Z]+" placeholder="First Name" />
<input id="field1" name="lastName" type="text" required pattern="[a-zA-Z]+" placeholder="Last Name" />
<input id="field4" name="emailAddress" type="text" required placeholder="Email" />
<input id="field2" name="company" type="text" placeholder="Company" />
<input id="field3" name="title" type="text" placeholder="Title" />
<input id="field5" name="busPhone" type="text" placeholder="Business Phone" />
<input id="field7" type="hidden" name="ViewNow" value="<?php echo get_post_meta($post->ID, 'asset-address', true); ?>" />
<input type="submit" value="Send" class="submit right btn btn--form">
\t \t </form>
<a class="close-reveal-modal">×</a>
<?php endwhile; ?> \t
</div>
是個甚至可能只用PHP或jQuery/JS是更好的解決方案?
我想JS解決方案將是一個更好的路線,謝謝。 –
同意! :-)如果它有幫助,你介意接受答案嗎? –
這將是正確的道路? https://jsfiddle.net/jxj3wm3o/ –