apply_filters( 'get_post_status', string $post_status, WP_Post $post )

Filters the post status.

Parameters Parameters


(string) The post status.


(WP_Post) The post object.

Top ↑

Source Source

File: wp-includes/post.php

View on Trac

Top ↑

Changelog Changelog

Version Description
5.7.0 The attachment post type is now passed through this filter.
4.4.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

  1. Skip to note 1 content

    Example: Changed post status of post id 1

    function wpdocs_change_post_status( $post_status, $post ) {
    	// Change post status for particular post
    	if ( 1 === $post->ID ) {
    		$post_status = 'publish';
    	return $post_status;
    add_filter( 'get_post_status', 'wpdocs_change_post_status', 10, 2 );

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