title: Need To Add A Class To Last List Item Element In Custom Wordpress Loop Function Prefer jQuery
body: <p>If have a fairly complex function we are using to generate a custom loop of 3 most recent posts. I am simply trying to add a class to the last li element called "last" but not really getting it down. I tried a bunch of jquery to addClass but no luck. I am sure it is just me being dumb. Any help would be greatly appreciate. Here is my function:</p>
  
  <pre><code>    &lt;?php function custom_readmore_after_excerpt($text) {  
          global $post;  
          //set default Read More 
              $link_text = '[continue]'; 
              $custom_fields = get_post_custom() ; 
              $thesis_content_fields = unserialize( $custom_fields['_thesis_post_content'][0] ); 
              if ( $thesis_content_fields['read_more'] )  
              $link_text = $thesis_content_fields['read_more']; 
  
              $link = '&lt;span&gt;&lt;a href="'. get_permalink($post-&gt;ID) . '" class="feed_read_more"&gt;' . $link_text . '&lt;/a&gt;&lt;/span&gt;';  
  
          if (!empty($post-&gt;post_excerpt)) {  
              $text = $text . $link;  
              } 
          else {  
              $text = str_replace('[...]', $link, $text);  
              }    
          return $text;   
          } 
          add_filter('get_the_excerpt', 'custom_readmore_after_excerpt');
  
  
              function excerpt_front($length) {
              return 16;
              }
  
              add_filter('excerpt_length', 'excerpt_front');
  
              $custom_loop = new WP_Query('showposts=3&amp;orderby=date');
              $output = "";
                  if ( $custom_loop-&gt;have_posts() ) : 
                      /* open box wrapper */
                      $output .= "&lt;ul class=\"feed_wrapper\"&gt;\n";
                  while ( $custom_loop-&gt;have_posts() ) : $custom_loop-&gt;the_post();
                      /* load post data */
                  global $post;
                      /* prepare necessary variables */
                      $img = "";
                      $post_url = get_permalink($post-&gt;ID);
                      $post_title = get_the_title($post-&gt;ID);
                      $post_excerpt = get_the_excerpt($post-&gt;ID);
                      $a_title = esc_attr($post_title); /* - double Title on some post .. humm ?? - */
                      $thumbnail_data = get_post_meta($post-&gt;ID, '_thesis_post_thumbnail', true);
                      /* do only if thumbanil_data is not empty and is an array of values */
                  if(!empty($thumbnail_data) &amp;&amp; is_array($thumbnail_data)) {
                      $thumbnail_url = (!empty($thumbnail_data['image']['url'])) ? $thumbnail_data['image']['url'] : "";
                      $img = "&lt;img src=\"{$thumbnail_url}\" class=\"feed_thumbnail\" alt=\"{$a_title}\" /&gt;";
                      }
                      $a_before = "&lt;a href=\"{$post_url}\"&gt;";
                      $a_after = "&lt;/a&gt;";
                      /* start html constructor */
                      /* open post wrapper */
                  $output .= "&lt;li&gt;\n&lt;div class=\"feed_container\"&gt;\n";
                  /* headline */
                  $output .= "&lt;div class=\"feed_headline\"&gt;\n&lt;h4 class=\"feed_title\"&gt;{$a_before}{$post_title}{$a_after}&lt;/h4&gt;\n&lt;/div&gt;\n";
                  /* thumbnail */
                  $output .= "&lt;div class=\"feed_thumb\"&gt;\n{$a_before}{$img}{$a_after}\n&lt;/div&gt;\n";
                  /* thumbnail */
                  $output .= "&lt;div class=\"feed_excerpt\"&gt;\n{$post_excerpt}&lt;/div&gt;\n";
                  /* close and clear post wrapper */
                  $output .= "&lt;div class=\"clear\"&gt;&lt;/div&gt;\n&lt;/div&gt;&lt;/li&gt;\n";
                  endwhile;
                  /* close and clear box wrapper */
              $output .= "&lt;div class=\"cleared\"&gt;&lt;/div&gt;\n&lt;/ul&gt;\n";
              endif;
              wp_reset_query();
              wp_reset_postdata();
              /* display result */
              echo $output; 
          ?&gt;
  </code></pre>