Remove class from first post listed??
-
I am trying to create a slider that automatically pulls posts from a certain category.
(See how it will eventually function here: https://benjamincharity.com/freelance/)
It needs to be set up like this (notice the style ‘display:none’ on all except first):
<div id="featured"> <div id="loopedSlider"> <ul class="nav-buttons"> <li><a href="#" class="previous">P</a></li> <li><a href="#" class="next">N</a></li> </ul> <div class="container"> <div class="slides"> <div id="slide1" class="slide"> SLIDE 1 CONTENT HERE </div> <!-- end .slide --> <div id="slide2" class="slide" style="display:none;"> SLIDE 2 CONTENT HERE </div> <!-- end .slide --> <div id="slide3" class="slide" style="display:none;"> SLIDE 3 CONTENT HERE </div> <!-- end .slide --> </div> <!-- end #slides --> </div><!-- .container ends --> <ul class="pagination"> <li><a href="#">1</a></li> <li><a href="#">2</a></li> <li><a href="#">3</a></li> <li><a href="#">4</a></li> </ul> </div> <!-- .content ends --> </div> <!-- #featured ends -->
So I changed the style addition to class=”displaynone” and used css to make that class display:none. I am just not sure how to either add that class to all of the slide divs other than the first, or remove that class from only the first.
Right now I have this code (I have added the displaynone class already, so in this example I would need to remove this class on the first item):
<div id="featured"> <div id="loopedSlider"> <ul class="nav-buttons"> <li id="p"><a href="#" class="previous"><img src="<?php bloginfo('template_url');?>/images/arrow-circle-left.png" alt="<" height="50px" width="50px" /></a></li> <li id="n"><a href="#" class="next"><img src="<?php bloginfo('template_url');?>/images/arrow-circle-right.png" alt=">" height="50px" width="50px" /></a></li> </ul> <div class="container"> <div class="slides"> <?php query_posts("cat=16"); global $more; // set $more to 0 in order to only get the first part of the post $more = 0; ?> <?php while (have_posts()) : the_post(); ?> <div id="post-<?php the_ID(); ?>" class="slide displaynone"> <h4><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h4> <div class="entry"> <?php the_content('<span class="moretext">[continue reading...]</span>'); ?> </div> <!-- end .entry --> </div> <!-- end .slide --> <?php endwhile; ?> </div> <!-- end #slides --> </div><!-- .end container --> <ul class="pagination"> <li><a href="#">1</a></li> <li><a href="#">2</a></li> <li><a href="#">3</a></li> <li><a href="#">4</a></li> </ul> </div> <!-- end #loopedSlider --> </div> <!-- end #featured -->
I am still trying to learn the ins and outs of PHP so I am quite lost on this. Any help would be so greatly appreciated as my site is almost finished except for this!
Thanks in advance,
Benjamin
- The topic ‘Remove class from first post listed??’ is closed to new replies.