Add post_class() template function for emitting standard classes for post div. see #7457

git-svn-id: https://develop.svn.wordpress.org/trunk@8638 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Ryan Boren 2008-08-13 19:09:08 +00:00
parent 2b8caf9a1f
commit 47194e9cd7
3 changed files with 29 additions and 2 deletions

View File

@ -6,7 +6,7 @@ get_header();
<?php the_date('','<h2>','</h2>'); ?> <?php the_date('','<h2>','</h2>'); ?>
<div class="post<?php sticky_class(); ?>" id="post-<?php the_ID(); ?>"> <div <?php post_class() ?> id="post-<?php the_ID(); ?>">
<h3 class="storytitle"><a href="<?php the_permalink() ?>" rel="bookmark"><?php the_title(); ?></a></h3> <h3 class="storytitle"><a href="<?php the_permalink() ?>" rel="bookmark"><?php the_title(); ?></a></h3>
<div class="meta"><?php _e("Filed under:"); ?> <?php the_category(',') ?> &#8212; <?php the_tags(__('Tags: '), ', ', ' &#8212; '); ?> <?php the_author() ?> @ <?php the_time() ?> <?php edit_post_link(__('Edit This')); ?></div> <div class="meta"><?php _e("Filed under:"); ?> <?php the_category(',') ?> &#8212; <?php the_tags(__('Tags: '), ', ', ' &#8212; '); ?> <?php the_author() ?> @ <?php the_time() ?> <?php edit_post_link(__('Edit This')); ?></div>

View File

@ -6,7 +6,7 @@
<?php while (have_posts()) : the_post(); ?> <?php while (have_posts()) : the_post(); ?>
<div class="post<?php sticky_class(); ?>" id="post-<?php the_ID(); ?>"> <div <?php post_class() ?> id="post-<?php the_ID(); ?>">
<h2><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></h2> <h2><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></h2>
<small><?php the_time('F jS, Y') ?> <!-- by <?php the_author() ?> --></small> <small><?php the_time('F jS, Y') ?> <!-- by <?php the_author() ?> --></small>

View File

@ -160,6 +160,33 @@ function has_excerpt( $id = 0 ) {
return ( !empty( $post->post_excerpt ) ); return ( !empty( $post->post_excerpt ) );
} }
/**
* Echo the classes for the post div
*
* {@internal Missing Long Description}}
*
* @package WordPress
* @subpackage Post
* @since 2.7
*
@ param string $class One or more classes to add to the class list
* @param int $post_id An optional post ID
*/
function post_class( $class = '', $post_id = null ) {
$classes = 'post';
if ( is_sticky($post_id) )
$classes .= ' sticky';
if ( !empty($class) )
$classes .= ' ' . $class;
$classes = apply_filters('post_class', $classes, $class, $post_id);
echo 'class="' . $classes . '"';
}
/** /**
* Echo "sticky" CSS class if a post is sticky * Echo "sticky" CSS class if a post is sticky
* *