Title: Remove class from first post listed??
Last modified: August 19, 2016

---

# Remove class from first post listed??

 *  [bencharity](https://wordpress.org/support/users/bencharity/)
 * (@bencharity)
 * [16 years, 6 months ago](https://wordpress.org/support/topic/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: [http://benjamincharity.com/freelance/](http://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

Viewing 2 replies - 1 through 2 (of 2 total)

 *  [Michael](https://wordpress.org/support/users/alchymyth/)
 * (@alchymyth)
 * [16 years, 6 months ago](https://wordpress.org/support/topic/remove-class-from-first-post-listed/#post-1273513)
 * have a look at this: [http://wordpress.org/support/topic/302408?replies=5](http://wordpress.org/support/topic/302408?replies=5)
 *  Thread Starter [bencharity](https://wordpress.org/support/users/bencharity/)
 * (@bencharity)
 * [16 years, 6 months ago](https://wordpress.org/support/topic/remove-class-from-first-post-listed/#post-1273587)
 * Thanks alchymyth!
 * However, using the code suggested (below) my entire page doesn’t render.
 * Also,
    If I want to pull only from a certain category, where would I put that
   call?
 * Using this:
 *     ```
       <?php if (have_posts()) : ?>
       <?php $post = $posts[0]; $c=0;?>
       <?php while (have_posts()) : the_post(); ?>
   
       <?php $c++;
       if( $c == 1) :?>
       <h1>The first post on the main index page</h1>
       <?php the_title(); ?>
       <?php the_excerpt(); ?>
   
       <?php else :?>
       <h2><?php the_title(); ?></h2>
       <?php the_content(); ?>
       <?php endif;?>
   
       <?php endwhile; ?>
       ```
   
 * I was using this:
 *     ```
       <?php
       query_posts("cat=16");
       global $more;
       // set $more to 0 in order to only get the first part of the post
       $more = 0;
       ?>
       ```
   
 * How would I call category 16 in the above code?
 * Thanks again!

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Remove class from first post listed??’ is closed to new replies.

## Tags

 * [query_posts](https://wordpress.org/support/topic-tag/query_posts/)

 * 2 replies
 * 2 participants
 * Last reply from: [bencharity](https://wordpress.org/support/users/bencharity/)
 * Last activity: [16 years, 6 months ago](https://wordpress.org/support/topic/remove-class-from-first-post-listed/#post-1273587)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
