Title: is_post_status_viewable
Published: March 9, 2021
Last modified: February 24, 2026

---

# is_post_status_viewable( string|stdClass $post_status ): bool

## In this article

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

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

Determines whether a post status is considered “viewable”.

## 󠀁[Description](https://developer.wordpress.org/reference/functions/is_post_status_viewable/?output_format=md#description)󠁿

For built-in post statuses such as publish and private, the ‘public’ value will 
be evaluated.
For all others, the ‘publicly_queryable’ value will be used.

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

 `$post_status`string|stdClassrequired

Post status name or object.

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

 bool Whether the post status should be considered viewable.

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

    ```php
    function is_post_status_viewable( $post_status ) {
    	if ( is_scalar( $post_status ) ) {
    		if ( ! is_string( $post_status ) ) {
    			return false;
    		}

    		$post_status = get_post_status_object( $post_status );

    		if ( ! $post_status ) {
    			return false;
    		}
    	}

    	if (
    		! is_object( $post_status ) ||
    		$post_status->internal ||
    		$post_status->protected
    	) {
    		return false;
    	}

    	$is_viewable = $post_status->publicly_queryable || ( $post_status->_builtin && $post_status->public );

    	/**
    	 * Filters whether a post status is considered "viewable".
    	 *
    	 * The returned filtered value must be a boolean type to ensure
    	 * `is_post_status_viewable()` only returns a boolean. This strictness
    	 * is by design to maintain backwards-compatibility and guard against
    	 * potential type errors in PHP 8.1+. Non-boolean values (even falsey
    	 * and truthy values) will result in the function returning false.
    	 *
    	 * @since 5.9.0
    	 *
    	 * @param bool     $is_viewable Whether the post status is "viewable" (strict type).
    	 * @param stdClass $post_status Post status object.
    	 */
    	return true === apply_filters( 'is_post_status_viewable', $is_viewable, $post_status );
    }
    ```

[View all references](https://developer.wordpress.org/reference/files/wp-includes/post.php/)
[View on Trac](https://core.trac.wordpress.org/browser/tags/6.9.4/src/wp-includes/post.php#L2457)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/6.9.4/src/wp-includes/post.php#L2457-L2495)

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

 [apply_filters( ‘is_post_status_viewable’, bool $is_viewable, stdClass $post_status )](https://developer.wordpress.org/reference/hooks/is_post_status_viewable/)

Filters whether a post status is considered “viewable”.

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

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

Retrieves a post status object by name.

  | 
| [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.

  |

| Used by | Description | 
| [wp_force_plain_post_permalink()](https://developer.wordpress.org/reference/functions/wp_force_plain_post_permalink/)`wp-includes/link-template.php` |

Determine whether post should always use a plain permalink structure.

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

Determines whether a post is publicly viewable.

  |

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

| Version | Description | 
| [5.9.0](https://developer.wordpress.org/reference/since/5.9.0/) | Added `is_post_status_viewable` hook to filter the result. | 
| [5.7.0](https://developer.wordpress.org/reference/since/5.7.0/) | Introduced. |

## User Contributed Notes

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