Uses
| Uses | Description |
|---|---|
| wp-admin/includes/template.php: get_post_states() | Retrieves an array of post states from a post. |
Function to echo or return the post states as HTML.
(WP_Post) (Required) The post to retrieve states for.
(bool) (Optional) Whether to echo the post states as an HTML string.
Default value: true
(string) Post states string.
File: wp-admin/includes/template.php
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;
} | Version | Description |
|---|---|
| 5.3.0 | Added the $echo parameter and a return value. |
| 2.7.0 | Introduced. |
© 2003–2019 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/functions/_post_states