Summery Summery
Function to echo or return the post states as HTML.
Syntax Syntax
Parameters Parameters
- $post
-
(Required) The post to retrieve states for.
- $echo
-
(Optional) Whether to echo the post states as an HTML string.
Default value: true
Return Return
(string) Post states string.
Source Source
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; }
Advertisement
Changelog Changelog
Version | Description |
---|---|
5.3.0 | Added the $echo parameter and a return value. |
2.7.0 | Introduced. |