Add more classes to post_class(). see #7457
git-svn-id: http://svn.automattic.com/wordpress/trunk@8641 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
9a95395188
commit
9e05ca767a
|
@ -28,7 +28,7 @@
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<?php while (have_posts()) : the_post(); ?>
|
<?php while (have_posts()) : the_post(); ?>
|
||||||
<div class="post">
|
<div <?php post_class() ?>>
|
||||||
<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>
|
<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>
|
||||||
<small><?php the_time('l, F jS, Y') ?></small>
|
<small><?php the_time('l, F jS, Y') ?></small>
|
||||||
|
|
||||||
|
|
|
@ -14,7 +14,7 @@
|
||||||
|
|
||||||
<?php while (have_posts()) : the_post(); ?>
|
<?php while (have_posts()) : the_post(); ?>
|
||||||
|
|
||||||
<div class="post">
|
<div <?php post_class() ?>>
|
||||||
<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>
|
<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>
|
||||||
<small><?php the_time('l, F jS, Y') ?></small>
|
<small><?php the_time('l, F jS, Y') ?></small>
|
||||||
|
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
<div class="alignright"><?php next_post_link('%link »') ?></div>
|
<div class="alignright"><?php next_post_link('%link »') ?></div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="post" id="post-<?php the_ID(); ?>">
|
<div <?php post_class() ?> id="post-<?php the_ID(); ?>">
|
||||||
<h2><?php the_title(); ?></h2>
|
<h2><?php the_title(); ?></h2>
|
||||||
|
|
||||||
<div class="entry">
|
<div class="entry">
|
||||||
|
|
|
@ -173,16 +173,37 @@ function has_excerpt( $id = 0 ) {
|
||||||
* @param int $post_id An optional post ID
|
* @param int $post_id An optional post ID
|
||||||
*/
|
*/
|
||||||
function post_class( $class = '', $post_id = null ) {
|
function post_class( $class = '', $post_id = null ) {
|
||||||
|
$post = get_post($post_id);
|
||||||
|
|
||||||
$classes = 'post';
|
$classes[] = $post->post_type;
|
||||||
|
|
||||||
if ( is_sticky($post_id) )
|
if ( is_sticky($post->ID) )
|
||||||
$classes .= ' sticky';
|
$classes[] = 'sticky';
|
||||||
|
|
||||||
if ( !empty($class) )
|
// hentry for hAtom compliace
|
||||||
$classes .= ' ' . $class;
|
$classes[] = 'hentry';
|
||||||
|
|
||||||
$classes = apply_filters('post_class', $classes, $class, $post_id);
|
// Categories
|
||||||
|
foreach ( (array) get_the_category($post->ID) as $cat ) {
|
||||||
|
if ( empty($cat->slug ) )
|
||||||
|
continue;
|
||||||
|
$classes[] = 'category-' . $cat->slug;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Tags
|
||||||
|
foreach ( (array) get_the_tags($post->ID) as $tag ) {
|
||||||
|
if ( empty($tag->slug ) )
|
||||||
|
continue;
|
||||||
|
$classes[] = 'tag-' . $tag->slug;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( !empty($class) ) {
|
||||||
|
$class = preg_split('#\s+#', $class);
|
||||||
|
$classes = array_merge($classes, $class);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Separates classes with a single space, collates classes for post DIV
|
||||||
|
$classes = join(' ', apply_filters('post_class', $classes, $class, $post_id));
|
||||||
|
|
||||||
echo 'class="' . $classes . '"';
|
echo 'class="' . $classes . '"';
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue