Introducing additional functions to check if a post is publicly viewable in WordPress 5.7

Introducing additional functions to check if a post is publicly viewable in WordPress 5.7

Author: WordPress.org

Date: February 18, 2021 

Category: Make WordPress Core

WordPress 5.7 introduces two additional functions to check if a post is publicly viewable.

Previously, the is_post_type_viewable() function was already available to determine if a post type is visible to anonymous users via the publicly_queryable setting when registering the post type. However, it wasn’t sufficient to determine if a specific post is viewable as this function only checks for general post type settings.

That’s why WordPress 5.7 introduces is_post_status_viewable() function, which allows developers to determine whether a post status is publicly viewable or not. Internal and protected statuses are never considered viewable. For built in posts statuses the public attribute is checked, for custom statuses the publicly_queryable attribute


World of WordPress is hosted by:

Rocket.net: Build Your Site on the Fastest WordPress Platform

With Rocket, your websites will be blazing fast, always protected, and supported 24/7 by our experts with over 17 years of experience.