Echoes or returns the post states as HTML.
Description
See also
Parameters
$post
WP_Postrequired- The post to retrieve states for.
$display
booloptional- Whether to display the post states as an HTML string.
Default:
true
Source
function _post_states( $post, $display = true ) {
$post_states = get_post_states( $post );
$post_states_string = '';
if ( ! empty( $post_states ) ) {
$state_count = count( $post_states );
$i = 0;
$post_states_string .= ' — ';
foreach ( $post_states as $state ) {
++$i;
$separator = ( $i < $state_count ) ? ', ' : '';
$post_states_string .= "<span class='post-state'>{$state}{$separator}</span>";
}
}
if ( $display ) {
echo $post_states_string;
}
return $post_states_string;
}
User Contributed Notes
You must log in before being able to contribute a note or feedback.