Note that there are some explanatory texts on larger screens.

plurals
  1. POChange an element's css class that resides outside a loop from inside a loop
    primarykey
    data
    text
    <pre><code>&lt;?php if ( have_posts() ) : ?&gt; &lt;?php $count = 1; $featuredPosts = 9; query_posts('showposts=19'); ?&gt; &lt;div class="articleTile column_3"&gt; &lt;?php while ( have_posts() ) : the_post(); ?&gt; &lt;?php if($count &gt; $featuredPosts) : ?&gt; &lt;!--change class to articleList column_2--&gt; &lt;?php endif; ?&gt; &lt;div class="column"&gt; &lt;?php get_template_part( 'content', 'featured' ); ?&gt; &lt;!-- #post-&lt;?php the_ID(); ?&gt; --&gt; &lt;/div&gt; &lt;?php $count = $count ++; endwhile; ?&gt; &lt;/div&gt; </code></pre> <p>How would I go about targeting the <code>&lt;div class="articleTile column_3"&gt;</code> element and changing its class when the count variable reaches 10?</p> <p>EDIT: I'm an idiot sorry.</p> <p>I've managed to do it with:</p> <pre><code>&lt;?php if ( have_posts() ) : ?&gt; &lt;?php $count = 1; $featuredPosts = 9; query_posts('showposts=19'); ?&gt; &lt;div class="articleTile column_3"&gt; &lt;?php while ( have_posts() ) : the_post(); ?&gt; &lt;?php if($count == $featuredPosts + 1) : ?&gt; &lt;?php echo $count ?&gt; &lt;/div&gt; &lt;div class="articleList column_2"&gt; &lt;?php endif; ?&gt; &lt;div class="column"&gt; &lt;?php echo $count ?&gt; &lt;?php get_template_part( 'content', 'featured' ); ?&gt; &lt;!-- #post-&lt;?php the_ID(); ?&gt; --&gt; &lt;/div&gt; &lt;?php $count = $count +1; endwhile; ?&gt; &lt;/div&gt; </code></pre> <p>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.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload