[wp-trac] [WordPress Trac] #18804: Add "has-post-thumbnail" class to post_class() when there's a featured image

WordPress Trac wp-trac at lists.automattic.com
Sat Dec 3 11:11:00 UTC 2011


#18804: Add "has-post-thumbnail" class to post_class() when there's a featured
image
------------------------------------+------------------------------
 Reporter:  danielbachhuber         |       Owner:  danielbachhuber
     Type:  enhancement             |      Status:  assigned
 Priority:  normal                  |   Milestone:  Awaiting Review
Component:  General                 |     Version:
 Severity:  minor                   |  Resolution:
 Keywords:  has-patch dev-feedback  |
------------------------------------+------------------------------
Changes (by donwilson):

 * cc: donwilson (added)


Comment:

 +1 as well, I just had a use for it in styling post archives with posts
 that have featured images and those that do not, it'd be nice to have this
 functionality in place.

 Here's a temporary filter for ''post_class()'' to provide this
 functionality:


 {{{
 function appendPostClassHasFeaturedImageClass($classes) {
         if(current_theme_supports('post-thumbnails'))
                 if(has_post_thumbnail())
                         $classes[] = "has-featured-image";

         return $classes;
 }       add_filter('post_class', "appendPostClassHasFeaturedImageClass");
 }}}

-- 
Ticket URL: <http://core.trac.wordpress.org/ticket/18804#comment:3>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list