私は自分のカウンターを数えようとしています。次を使用して、表示されるすべての投稿にクラス名(偶数)を追加しようとしています:
<?php
global $paged;
global $post;
$do_not_duplicate = array();
$categories = get_the_category();
$category = $categories[0];
$cat_ID = $category->cat_ID;
$myposts = get_posts('category='.$cat_ID.'&paged='.$paged);
$do_not_duplicate[] = $post->ID;
$c = 0;
$c++;
if( $c == 2) {
$style = 'even animated fadeIn';
$c = 0;
}
else $style='animated fadeIn';
?>
<?php foreach($myposts as $post) :?>
// Posts outputted here
<?php endforeach; ?>
even
クラス名が出力されていません。出力される唯一のクラス名は、(ifステートメントのelse部分からの)animated
およびFadeIn
クラスであり、現時点ですべての投稿に追加されます