Skip to Content

post_classes()

Adds useful information to post tags as classes.

PHP March 16, 2017

Usage

This function runs automatically, so it is not called manually. Is this incorrect?

Source File

Located in /libs/Functions.php on line 2808.

No Hooks

This function does not have any filters or actions available. Request one?
PHP
    public function post_classes($classes){
        $this->timer('Nebula Post Classes');

        global $post;
        global $wp_query;

        if ( $wp_query->current_post === 0 ){ //If first post in a query
            $classes[] = 'first-post';
        }
        if ( is_sticky() ){
            $classes[] = 'sticky';
        }
        $classes[] = 'nebula-entry';

        if ( !is_page() ){
            $classes[] = 'date-day-' . strtolower(get_the_date('l'));
            $classes[] = 'date-ymd-' . strtolower(get_the_date('Y-m-d'));
            $classes[] = 'date-month-' . strtolower(get_the_date('F'));
        }

        if ( !empty($post) ){
            foreach ( get_the_category($post->ID) as $category ){
                $classes[] = 'cat-id-' . $category->cat_ID;
            }
        }

        $classes[] = 'author-id-' . $post->post_author;
        if ( is_multi_author() ){
            $classes[] = 'multi-author';
        }

        //Remove "hentry" meta class on pages or if Author Bios are disabled
        if ( is_page() || !$this->get_option('author_bios') ){
            $classes = array_diff($classes, array('hentry'));
        }

        $this->timer('Nebula Post Classes', 'end');
        return $classes;
    }

Override

This function can not be short-circuited with an override filter. Request one?