wordpressのトップページ内で新着記事を表示したいと考えています。
画像と新着記事のタイトルなどを三つ、縦ではなく横に並べたいとした時、どのように表記したらいいかわからず困っております。ご教授いただけたら幸いです。
indepx.php
<div class="site-section"> <div class="container"> <div class="row mb-5"> <div class="col-md-12"> <h2 class="site-section-heading text-center">最新情報</h2> <span class="caption d-block text-black text-center">NEWS</span> </div> </div> <?php $infoPosts = get_posts('numberposts=3&category=4'); foreach($infoPosts as $post): ?> <div class="row mb-5"> <div class="col-md-4 col-lg-4 mb-5 mb-lg-4"> <div class="media-with-text mb-4"> <div class="mb-4"> <a href="#"> <img src="<?php bloginfo( 'stylesheet_directory' ); ?>/images/img_1.jpg" alt="" class="img-fluid"> </a> </div> <h2 class="h5 mb-2"><a href="#"><?php the_title(); ?></a></h2> <span class="mb-3 d-block post-date"><?php the_time('Y/m/d'); ?>By <a href="#">harry black</a></span> <p>新しいニュースです。新しいニュースです。新しいニュースです。新しいニュースです。新しいニュースです。</p> </div> </div> </div> <?php endforeach; ?> </div> </div>
テーマは自作のHTMLです。
CSS表記はこうなっております。
CSS
1.site-section { 2 padding: 3em 0; } 3 @media (min-width: 768px) { 4 .site-section { 5 padding: 7em 0; } } 6 .site-section.site-section-sm { 7 padding: 4em 0; }``` 8 9現時点では縦並びで三つ表示されております。
ブロックを横に並べるのは、 CSS の役目ですので、お使いのテーマ名 と CSS も提示してください。
回答3件
あなたの回答
tips
プレビュー