post_class()
will echo the class in the formatclass="postclassA
postclassB"get_post_class()
will return an array of all registred
classes
To use get_post_class()
inside sprintf()
, you have to return the array as a string. For this purpose you can use the join()
function.
Example
$classes = join(' ', get_post_class())
$sidebar = sprintf('<div id="post-%s" class="%s">%s</div>', get_the_ID(), $classes, get_the_content());