Add Various Post Related Classes

Fundamental 36 views
0
0 Flares 0 Flares ×

The post_class may include one or more of the following values for the class attribute, dependent upon the pageview.

  • .post-id
  • .post
  • .attachment
  • .sticky
  • .hentry (hAtom microformat pages)
  • .category-ID
  • .category-name
  • .tag-name
  • .format-name

Usage

<div id="post-<?php the_ID(); ?>" <?php post_class(); ?>>

Add custom classes as well:

<div id="post-<?php the_ID(); ?>" <?php post_class('class-name'); ?>>

Output

(Just an example)

<div id="post-4564" class="class-name post post-4564 category-48 category-dancing logged-in">

For Reference:

Function Reference/post class

Provided by: Wordpress Codex
Posted in Wordpress

Discuss:

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

No Trackbacks.

Login

Register | Lost your password?
0 Flares Twitter 0 Facebook 0 Google+ 0 0 Flares ×