Loop Statement inside WP Loop
-
Hello to all,
I need some help with a loop statement. For example we have the base WP Loop and I need another loop inside it to create separate CSS Classes for the first 3 loops. Check the code below:
<?php if (have_posts()) : ?> <?php while (have_posts()) : the_post(); ?> for ($i=1; $i<13; $i++) { echo $i; } <a class="<?php for ($i=1; $i<4; $i++) { echo $i; } ?>" href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>"><?php the_title(); ?></a> <?php endwhile; ?>
But the code will generate:
class=”123″
and I need to set only a number per posts, like this:
class=”1″ – for Post 1
class=”2″ – for Post 2
class=”3″ – for Post 3
and again for the next 3 posts
class=”1″ – for Post 4
class=”2″ – for Post 5
class=”3″ – for Post 6Waiting for some help please. Thank you!
Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
- The topic ‘Loop Statement inside WP Loop’ is closed to new replies.