WordPress.org

Make WordPress Core

Ticket #22271: 22271_1.patch

File 22271_1.patch, 1.3 KB (added by F J Kaiser, 6 years ago)

Adds the post_class filter for requests where no post ID is present

  • wp-includes/post-template.php

     
    299299/**
    300300 * Retrieve the classes for the post div as an array.
    301301 *
    302  * The class names are add are many. If the post is a sticky, then the 'sticky'
    303  * class name. The class 'hentry' is always added to each post. For each
    304  * category, the class will be added with 'category-' with category slug is
    305  * added. The tags are the same way as the categories with 'tag-' before the tag
    306  * slug. All classes are passed through the filter, 'post_class' with the list
    307  * of classes, followed by $class parameter value, with the post ID as the last
    308  * parameter.
     302 * There are many class names added. 'sticky' if the post is sticky.
     303 * 'hentry' for all. 'category-[slug id]' for categories, same for tags.
     304 * All classes are passed through the filter 'post_class' with the list
     305 * of classes, which is then followed by the $class argument value,
     306 * with the $post_id as the last argument.
    309307 *
    310308 * @since 2.7.0
    311309 *
     
    319317        $classes = array();
    320318
    321319        if ( empty($post) )
    322                 return $classes;
     320                return apply_filters('post_class', $classes, explode( ' ', $class ), null);
    323321
    324322        $classes[] = 'post-' . $post->ID;
    325323        if ( ! is_admin() )