I’m trying to create a parallax page similar to https://www.spotify.com/uk/ setup, and have each post from a specific category come up, followed by a parallax scrolling image background under it.
So I’ve added the background image code to be inserted automatically as each post is pulled, I know how many posts will be on the homepage, I just want to give the client the freedom to edit the content of them, so having too many isn’t going to be an issue, but, I need to have an automatically generated class name based on a loop, so I can add the background-image using CSS to it, such as background1, background 2, background 3, etc..
This is my code currently
<?php query_posts('cat=2');?> <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?> <div class="postWrap"> <div class="postContainer"> <h1> <a href="<?php the_permalink(); ?>"><?php the_title(); ?></a> </h1> <p> <?php the_content(); ?> </div> </div> <section class="[LOOP HELP HERE]" data-speed="4" data-type="background"> <h2>Image goes here</h2> </section> <?php endwhile; else: endif; ?>
Can someone help patch me up with the PHP side of this?
- The topic ‘CSS class name based on incremental PHP name loop’ is closed to new replies.