私はindex.phpファイル内の3つの投稿をすべて行divに追加したいのですが、最初の投稿を除外して、最初の投稿は異なっています。wordpressはループ内の最初の投稿の後に1つのdiv内の3つの投稿をすべてラップします
私は現在、ループはすべての3つの記事のために働いてきたが、私はそれ特集記事
以下は私のコード
<div class="content post-main__content clearfix" id="post-<?php the_ID(); ?>" >
<?php
if(have_posts()) : for($count=0;have_posts();$count++) : the_post();
$open = !($count%3) ? '<div class="post-main__row clearfix">' : ''; //Create open wrapper if count is divisible by 3
$close = !($count%3) && $count ? '</div>' : ''; //Close the previous wrapper if count is divisible by 3 and greater than 0
echo $close.$open;
?>
<div class="post-main__cell">
<a href="<?php the_permalink() ?>" rel="bookmark" title="Click to go to <?php the_title(); ?>">
<div class="post-main__cell-top">
<?php the_post_thumbnail(array(330, 167,)); ?>
<h3 class="content__category-name <?php foreach((get_the_category()) as $category) { echo $category->cat_name. ''; } ?>">
<?php foreach((get_the_category()) as $category) { echo $category->cat_name . ' '; } ?>
</h3>
</div>
<div class="post-main__cell-bottom">
<h2 class="archive-header"><?php the_title() ?></h2>
<p class="paragraph--time"><?php posted_on(); ?></p>
</div>
</a>
</div>
<?php endfor; else : ?>
であることを確認するために、異なる最初の投稿を最初のポストとスタイルを除外したいと思います
<?php echo $count ? '</div>' : ''; //Close the last wrapper if post count is greater than 0 ?>