Make WordPress Core

Changeset 8641


Ignore:
Timestamp:
08/13/2008 09:58:06 PM (18 years ago)
Author:
ryan
Message:

Add more classes to post_class(). see #7457

Location:
trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-content/themes/default/archive.php

    r6942 r8641  
    2929
    3030                <?php while (have_posts()) : the_post(); ?>
    31                 <div class="post">
     31                <div <?php post_class() ?>>
    3232                                <h3 id="post-<?php the_ID(); ?>"><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></h3>
    3333                                <small><?php the_time('l, F jS, Y') ?></small>
  • trunk/wp-content/themes/default/search.php

    r6132 r8641  
    1515                <?php while (have_posts()) : the_post(); ?>
    1616
    17                         <div class="post">
     17                        <div <?php post_class() ?>>
    1818                                <h3 id="post-<?php the_ID(); ?>"><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></h3>
    1919                                <small><?php the_time('l, F jS, Y') ?></small>
  • trunk/wp-content/themes/default/single.php

    r7582 r8641  
    1010                </div>
    1111
    12                 <div class="post" id="post-<?php the_ID(); ?>">
     12                <div <?php post_class() ?> id="post-<?php the_ID(); ?>">
    1313                        <h2><?php the_title(); ?></h2>
    1414
  • trunk/wp-includes/post-template.php

    r8639 r8641  
    174174 */
    175175function post_class( $class = '', $post_id = null ) {
    176 
    177         $classes = 'post';
    178 
    179         if ( is_sticky($post_id) )
    180                 $classes .= ' sticky';
    181 
    182         if ( !empty($class) )
    183                 $classes .= ' ' . $class;
    184 
    185         $classes = apply_filters('post_class', $classes, $class, $post_id);
     176        $post = get_post($post_id);
     177
     178        $classes[] = $post->post_type;
     179
     180        if ( is_sticky($post->ID) )
     181                $classes[] = 'sticky';
     182
     183        // hentry for hAtom compliace
     184        $classes[] = 'hentry';
     185
     186        // Categories
     187        foreach ( (array) get_the_category($post->ID) as $cat ) {
     188                if ( empty($cat->slug ) )
     189                        continue;
     190                $classes[] = 'category-' . $cat->slug;
     191        }
     192
     193        // Tags
     194        foreach ( (array) get_the_tags($post->ID) as $tag ) {
     195                if ( empty($tag->slug ) )
     196                        continue;
     197                $classes[] = 'tag-' . $tag->slug;
     198        }
     199
     200        if ( !empty($class) ) {
     201                $class = preg_split('#\s+#', $class);
     202                $classes = array_merge($classes, $class);
     203        }
     204
     205        // Separates classes with a single space, collates classes for post DIV
     206        $classes = join(' ', apply_filters('post_class', $classes, $class, $post_id));
    186207
    187208        echo 'class="' . $classes . '"';
Note: See TracChangeset for help on using the changeset viewer.