WordPress at Your Fingertips
function is not described

_post_states() WP 2.7.0

Function to echo or return the post states as HTML.

This is an internal function for using it by WP core itself. It's not recommended to use this function in your code.

No Hooks.

Return

String. Post states string.

Usage

_post_states( $post, $echo );
$post(WP_Post) (required)
The post to retrieve states for.
$echo(true|false)
Whether to echo the post states as an HTML string.
Default: true

Notes

Changelog

Since 2.7.0 Introduced.
Since 5.3.0 Added the $echo parameter and a return value.

Code of _post_states() WP 5.8.2

function _post_states( $post, $echo = 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 ) {
			$sep = ( ++$i === $state_count ) ? '' : ', ';

			$post_states_string .= "<span class='post-state'>$state$sep</span>";
		}
	}

	if ( $echo ) {
		echo $post_states_string;
	}

	return $post_states_string;
}