wpseek.com
WordPress开发者和主题制作者的搜索引擎



_post_states › WordPress Function

Since2.7.0
已弃用n/a
_post_states ( $post, $display = true )
参数: (2)
  • (WP_Post) $post The post to retrieve states for.
    Required: Yes
  • (bool) $display Optional. Whether to display the post states as an HTML string. Default true.
    Required: No
    默认: true
查看:
返回:
  • (string) Post states string.
定义在:
文档:
Change Log:
  • 5.3.0

Echoes or returns the post states as HTML.



源码

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;
}