apply_filters( 'display_post_states', string[] $post_states, WP_Post $post )

Filters the default post display states used in the posts list table.


$post_states string[]
An array of post display states.
$post WP_Post
The current post object.

Top ↑


File: wp-admin/includes/template.php. View all references

return apply_filters( 'display_post_states', $post_states, $post );

Top ↑


Version Description
5.5.0 Also applied in the Customizer context. If any admin functions are used within the filter, their existence should be checked with function_exists() before being used.
3.6.0 Added the $post parameter.
2.8.0 Introduced.

Top ↑

User Contributed Notes

  1. Skip to note 1 content
    Contributed by Pixelbart

    This always shows the current post status in the labels. This is especially useful when adding many custom post states.

     * This always shows the current post status in the labels.
     * @param array   $states current states.
     * @param WP_Post $post current post object.
     * @return array
    function custom_display_post_states( $states, $post ) {
    	/* Receive the post status object by post status name */
    	$post_status_object = get_post_status_object( $post->post_status );
    	/* Checks if the label exists */
    	if ( in_array( $post_status_object->label, $states, true ) ) {
    		return $states;
    	/* Adds the label of the current post status */
    	$states[ $post_status_object->name ] = $post_status_object->label;
    	return $states;
    add_filter( 'display_post_states', 'custom_display_post_states', 10, 2 );

You must log in before being able to contribute a note or feedback.