On this page
_post_states( WP_Post $post, bool $display = true ): string
Echoes or returns the post states as HTML.
Description
See also
Parameters
$postWP_Post Required-
The post to retrieve states for.
$displaybool Optional-
Whether to display the post states as an HTML string.
Default:
true
Return
string Post states string.
Source
File: wp-admin/includes/template.php. View all references
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;
}
Related
Uses
| Uses | Description |
|---|---|
| get_post_states() wp-admin/includes/template.php | Retrieves an array of post states from a post. |
Used By
| Used By | Description |
|---|---|
| WP_Posts_List_Table::column_title() wp-admin/includes/class-wp-posts-list-table.php | Handles the title column output. |
| Walker_Nav_Menu_Checklist::start_el() wp-admin/includes/class-walker-nav-menu-checklist.php | Start the element output. |
Changelog
© 2003–2022 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/functions/_post_states