Slick sliderを使用しているのですが、スライダー内でwordpressの記事をクリックした時に、その記事のコンテンツを表示するモーダルを実装したいです。下記のコードですと、記事をクリックするとモーダルがスライダー内のみで表示され、window全体にfixedで表示されません。
アドバイスをいただけませんでしょうか…。
補足
こちらの記事を参考にしたのですが、うまくいきませんでした。
html
1 <ul class="slider-article"> 2 <?php 3 $news_query = new WP_Query( 4 array( 5 'post_type' => 'post', 6 'posts_per_page' => 7, 7 ) 8 ); 9 ?> 10 <?php if ( $news_query->have_posts() ) : ?> 11 <?php while ( $news_query->have_posts() ) : ?> 12 <?php $news_query->the_post(); ?> 13 <li> 14 <article> 15 <div class="open"> 16 <figure> 17 <div class="img-wrapper"> 18 <?php if(has_post_thumbnail()) : ?> 19 <?php the_post_thumbnail(); ?> 20 <?php else : ?> 21 <img src="<?php echo get_template_directory_uri(); ?>/img/noimage.png" alt="noimage"> 22 <?php endif; ?> 23 </div> 24 </figure> 25 <div class="text-area"> 26 <div class="date"> 27 <time datetime="<?php the_time('Y-m-d'); ?>"><?php the_time('Y.m.d'); ?></time> 28 </div> 29 <h3><?php the_title(); ?></h3> 30 </div> 31 <div class="modal"> 32 <div class="modal-box"> 33 <?php the_content(); ?> 34 </div> 35 </div> 36 </div> 37 </article> 38 </li> 39 <?php endwhile; ?> 40 <?php endif; ?> 41 <?php wp_reset_postdata(); ?> 42 </ul>
scss
1 .modal { 2 background: rgba(0, 0, 0, 0.38); 3 display: none; 4 width: 100vw; 5 height: 100vh; 6 top: 0; 7 left: 0; 8 right: 0; 9 bottom: 0; 10 justify-content: center; 11 align-items: center; 12 position: fixed; 13 z-index:9999; 14 15 .modal-box { 16 height: 50%; 17 width: 50%; 18 padding: 40px; 19 overflow: auto; 20 background: #000; 21 } 22 }
js
1$(function() { 2 $('.open').click(function(){ 3 $('.modal').fadeIn(); 4 }); 5 $('.close').click(function(){ 6 $('.modal').fadeOut(); 7 }); 8}); 9 10$(window).on('load', function() { 11 $('.slick-cloned a').removeAttr('rel'); 12});
あなたの回答
tips
プレビュー