2017-01-22 2 views
1

col-md-4を使用して1つの行に3つの投稿を表示するループがあります。この行をdivにラップする方法はありますか?今、私がcssをcol-md-4に追加すると、それは個々の投稿にcssを適用し、むしろcssは行の3つの投稿に一括して影響を与えます。誰も私がこれをどうやってできるか知っていますか?1つの行に3つの投稿を1つのdivにまとめる方法

フロント-page.php

<?php 
 
/* 
 
* Template Name: 
 
*/ 
 

 
get_header(); 
 
get_template_part ('inc/carousel'); 
 

 
$the_query = new WP_Query([ 
 
    'posts_per_page' => 14, 
 
    'paged' => get_query_var('paged', 1) 
 
]); 
 

 
if ($the_query->have_posts()) { ?> 
 
    <div id="ajax"> 
 
    <?php 
 
    $i = 0; 
 
    while ($the_query->have_posts()) { $the_query->the_post(); 
 

 
     if ($i % 7 === 0) { // Large post: on the first iteration and every 7th post after... ?> 
 
     <article <?php post_class('col-md-12'); ?>> 
 
      <div class="large-front-container"> 
 
<?php the_post_thumbnail('full', array('class' => 'large-front-thumbnail')); ?> 
 
       </div> 
 
      <h2><a class="post-title" href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2> 
 
      <p class="front-page-post-excerpt"><?php echo get_the_excerpt(); ?></p> 
 
      <div class="front-post-info"> 
 
      <a class="moretext" href="<?php the_permalink(); ?>">Read more</a> 
 
       <?php get_template_part ('front-page-shop'); ?> 
 
           <?php get_template_part('share-buttons'); ?> 
 
       <div class="front-comments"><?php comments_popup_link ('0', '1', '%', 'comment-count', 'none'); ?></div> 
 
      </article><?php 
 

 
     } else { // Small posts ?> 
 
      <article <?php post_class('col-md-4'); ?>> 
 
       <div class="front-thumbnail-image"><?php the_post_thumbnail('full', array('class' => 'medium-front-thumbnail')); ?></div> 
 
       <a class="front-page-post-title" href="<?php the_permalink(); ?>"><?php the_title(); ?></a> 
 
       <p class="front-page-post-excerpt"><?php echo get_the_excerpt(); ?></p> 
 
       <a class="moretext" href="<?php the_permalink(); ?>">Read more</a> 
 
       <?php get_template_part ('front-page-shop'); ?> 
 
           <?php get_template_part('share-buttons'); ?> 
 
       <div class="front-comments"><?php comments_popup_link ('0', '1', '%', 'comment-count', 'none'); ?></div> 
 
      </article> 
 
      <?php 
 
     } 
 
     $i++; 
 
    }?> 
 
    </div> 
 
    <?php if(get_query_var('paged') < $the_query->max_num_pages) { 
 
     load_more_button(); 
 
    } 
 
} 
 
elseif (!get_query_var('paged') || get_query_var('paged') == '1') { 
 
    echo '<p>Sorry, no posts matched your criteria.</p>'; 
 
} 
 
wp_reset_postdata(); 
 
get_footer();

答えて

0

でポストコンテナ/親要素をスタイリングしてみFlexBox

関連する問題