WordPress 7.1.4Etch Theme 0.0.7Etch 1.7.1Automatic.css 4.0.1
Good evening! Today is October 28, 2026
the repo

By Stephen Walker

Show Post Status

If you work with numerous non-published posts, it might be helpful to show the status. This shortcode shows the status if the status is currently not “Publish.”

Published 1 min read

The snippet

If you work with numerous non-published posts, it might be helpful to show the status. This shortcode shows the status if the status is currently not “Publish.”

function current_post_status_shortcode($atts) {
    global $post;

    // Check if we are inside a post
    if (!isset($post->ID)) {
        return '';
    }

    // Get the post status
    $status = get_post_status($post->ID);

    // Check the post status
    if($status != 'publish') {
        return $status;
    }

    // If post status is 'publish', we return an empty string
    return '';
}
add_shortcode('post_status', 'current_post_status_shortcode');