Title: get_post_states
Published: November 12, 2019
Last modified: May 20, 2026

---

# get_post_states( WP_Post $post ): string[]

## In this article

 * [Parameters](https://developer.wordpress.org/reference/functions/get_post_states/?output_format=md#parameters)
 * [Return](https://developer.wordpress.org/reference/functions/get_post_states/?output_format=md#return)
 * [Source](https://developer.wordpress.org/reference/functions/get_post_states/?output_format=md#source)
 * [Hooks](https://developer.wordpress.org/reference/functions/get_post_states/?output_format=md#hooks)
 * [Related](https://developer.wordpress.org/reference/functions/get_post_states/?output_format=md#related)
 * [Changelog](https://developer.wordpress.org/reference/functions/get_post_states/?output_format=md#changelog)

[ Back to top](https://developer.wordpress.org/reference/functions/get_post_states/?output_format=md#wp--skip-link--target)

Retrieves an array of post states from a post.

## 󠀁[Parameters](https://developer.wordpress.org/reference/functions/get_post_states/?output_format=md#parameters)󠁿

 `$post`[WP_Post](https://developer.wordpress.org/reference/classes/wp_post/)required

The post to retrieve states for.

## 󠀁[Return](https://developer.wordpress.org/reference/functions/get_post_states/?output_format=md#return)󠁿

 string[] Array of post state labels keyed by their state.

## 󠀁[Source](https://developer.wordpress.org/reference/functions/get_post_states/?output_format=md#source)󠁿

    ```php
    function get_post_states( $post ) {
    	$post_states = array();
    	if ( ! $post instanceof WP_Post ) {
    		return $post_states;
    	}

    	$post_status = $_REQUEST['post_status'] ?? '';

    	if ( ! empty( $post->post_password ) ) {
    		$post_states['protected'] = _x( 'Password protected', 'post status' );
    	}

    	if ( 'private' === $post->post_status && 'private' !== $post_status ) {
    		$post_states['private'] = _x( 'Private', 'post status' );
    	}

    	if ( 'draft' === $post->post_status ) {
    		if ( get_post_meta( $post->ID, '_customize_changeset_uuid', true ) ) {
    			$post_states[] = __( 'Customization Draft' );
    		} elseif ( 'draft' !== $post_status ) {
    			$post_states['draft'] = _x( 'Draft', 'post status' );
    		}
    	} elseif ( 'trash' === $post->post_status && get_post_meta( $post->ID, '_customize_changeset_uuid', true ) ) {
    		$post_states[] = _x( 'Customization Draft', 'post status' );
    	}

    	if ( 'pending' === $post->post_status && 'pending' !== $post_status ) {
    		$post_states['pending'] = _x( 'Pending', 'post status' );
    	}

    	if ( is_sticky( $post->ID ) ) {
    		$post_states['sticky'] = _x( 'Sticky', 'post status' );
    	}

    	if ( 'future' === $post->post_status ) {
    		$post_states['scheduled'] = _x( 'Scheduled', 'post status' );
    	}

    	if ( 'page' === get_option( 'show_on_front' ) ) {
    		if ( (int) get_option( 'page_on_front' ) === $post->ID ) {
    			$post_states['page_on_front'] = _x( 'Front Page', 'page label' );
    		}

    		if ( (int) get_option( 'page_for_posts' ) === $post->ID ) {
    			$post_states['page_for_posts'] = _x( 'Posts Page', 'page label' );
    		}
    	}

    	if ( (int) get_option( 'wp_page_for_privacy_policy' ) === $post->ID ) {
    		$post_states['page_for_privacy_policy'] = _x( 'Privacy Policy Page', 'page label' );
    	}

    	/**
    	 * Filters the default post display states used in the posts list table.
    	 *
    	 * @since 2.8.0
    	 * @since 3.6.0 Added the `$post` parameter.
    	 * @since 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.
    	 *
    	 * @param array<string, string>  $post_states A mapping of post state slugs to translated post state labels.
    	 *                                            E.g. `array( 'draft' => __( 'Draft' ), 'sticky' => __( 'Sticky' ), ... )`.
    	 * @param WP_Post                $post        The current post object.
    	 */
    	return apply_filters( 'display_post_states', $post_states, $post );
    }
    ```

[View all references](https://developer.wordpress.org/reference/files/wp-admin/includes/template.php/)
[View on Trac](https://core.trac.wordpress.org/browser/tags/7.0/src/wp-admin/includes/template.php#L2303)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/7.0/src/wp-admin/includes/template.php#L2303-L2369)

## 󠀁[Hooks](https://developer.wordpress.org/reference/functions/get_post_states/?output_format=md#hooks)󠁿

 [apply_filters( ‘display_post_states’, array<string, , WP_Post $post )](https://developer.wordpress.org/reference/hooks/display_post_states/)

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

## 󠀁[Related](https://developer.wordpress.org/reference/functions/get_post_states/?output_format=md#related)󠁿

| Uses | Description | 
| [is_sticky()](https://developer.wordpress.org/reference/functions/is_sticky/)`wp-includes/post.php` |

Determines whether a post is sticky.

  | 
| [_x()](https://developer.wordpress.org/reference/functions/_x/)`wp-includes/l10n.php` |

Retrieves translated string with gettext context.

  | 
| [__()](https://developer.wordpress.org/reference/functions/__/)`wp-includes/l10n.php` |

Retrieves the translation of $text.

  | 
| [apply_filters()](https://developer.wordpress.org/reference/functions/apply_filters/)`wp-includes/plugin.php` |

Calls the callback functions that have been added to a filter hook.

  | 
| [get_option()](https://developer.wordpress.org/reference/functions/get_option/)`wp-includes/option.php` |

Retrieves an option value based on an option name.

  | 
| [get_post_meta()](https://developer.wordpress.org/reference/functions/get_post_meta/)`wp-includes/post.php` |

Retrieves a post meta field for the given post ID.

  |

[Show 4 more](https://developer.wordpress.org/reference/functions/get_post_states/?output_format=md#)
[Show less](https://developer.wordpress.org/reference/functions/get_post_states/?output_format=md#)

| Used by | Description | 
| [WP_Customize_Nav_Menus::search_available_items_query()](https://developer.wordpress.org/reference/classes/wp_customize_nav_menus/search_available_items_query/)`wp-includes/class-wp-customize-nav-menus.php` |

Performs post queries for available-item searching.

  | 
| [WP_Customize_Nav_Menus::load_available_items_query()](https://developer.wordpress.org/reference/classes/wp_customize_nav_menus/load_available_items_query/)`wp-includes/class-wp-customize-nav-menus.php` |

Performs the post_type and taxonomy queries for loading available menu items.

  | 
| [_post_states()](https://developer.wordpress.org/reference/functions/_post_states/)`wp-admin/includes/template.php` |

Echoes or returns the post states as HTML.

  | 
| [wp_setup_nav_menu_item()](https://developer.wordpress.org/reference/functions/wp_setup_nav_menu_item/)`wp-includes/nav-menu.php` |

Decorates a menu item object with the shared navigation menu item properties.

  |

## 󠀁[Changelog](https://developer.wordpress.org/reference/functions/get_post_states/?output_format=md#changelog)󠁿

| Version | Description | 
| [5.3.0](https://developer.wordpress.org/reference/since/5.3.0/) | Introduced. |

## User Contributed Notes

You must [log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fget_post_states%2F)
before being able to contribute a note or feedback.