wordpress post_class code example

Example 1: 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 2: 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">

Tags:

Php Example