post_class() code example
Example 1: what is post_class()
/* we see in php code */
<div id="post-<?php the_ID(); ?>" <?php post_class( 'class-name' ); ?>>
/* we see in html code like this */
<div id="post-4564" class="class-name post-4564 post type-post status-publish format-standard hentry category-news">
Example 2: what is post_class()
/* Use an array to add multiple classes in post_class() function: */
<?php
$classes = array(
'class1',
'class2',
'class3',
);
?>
<div id="post-<?php the_ID(); ?>" <?php post_class( $classes ); ?>>
Example 3: what is post_class()
/* A simple way to add multiple classes to the post_class defaults, is to just write them as a string argument: */
<div <?php post_class( 'class1 class2 class3' ); ?>>