<?php if ( have_posts() ) : ?>
<?php
$count = 1;
$featuredPosts = 9;
query_posts('showposts=19');
?>
<div class="articleTile column_3">
<?php while ( have_posts() ) : the_post(); ?>
<?php if($count > $featuredPosts) : ?>
<!--change class to articleList column_2-->
<?php endif; ?>
<div class="column">
<?php get_template_part( 'content', 'featured' ); ?>
<!-- #post-<?php the_ID(); ?> -->
</div>
<?php
$count = $count ++;
endwhile;
?>
</div>
How would I go about targeting the <div class="articleTile column_3"> element and changing its class when the count variable reaches 10?
EDIT: I’m an idiot sorry.
I’ve managed to do it with:
<?php if ( have_posts() ) : ?>
<?php
$count = 1;
$featuredPosts = 9;
query_posts('showposts=19');
?>
<div class="articleTile column_3">
<?php while ( have_posts() ) : the_post(); ?>
<?php if($count == $featuredPosts + 1) : ?>
<?php echo $count ?>
</div>
<div class="articleList column_2">
<?php endif; ?>
<div class="column">
<?php echo $count ?>
<?php get_template_part( 'content', 'featured' ); ?>
<!-- #post-<?php the_ID(); ?> -->
</div>
<?php
$count = $count +1;
endwhile;
?>
</div>
My original way wouldn’t have worked anyway without a 2nd element with a different class. My apologies. Thanks for the fast responses they helped point me in the right direction.
Isn’t it smarter to just run the a loop first to check what the total count is gonna be and then use it to set the right class?
Something like this perhaps? :