Exciting News! Flipper Code is now WePlugins! Same commitment to excellence, brand new identity.

How to use post_date_column_status filter in WordPress

Sandeep Kumar Mishra
Sandeep Kumar Mishra
July 5, 2022
5 minutes read

post_date_column_status filter

Filters the status text of the post.

 apply_filters( 'post_date_column_status', string $status, WP_Post $post, string $column_name, string $mode ) 

Description

This hook is used for filter of status text of a post.

By using this hook we can get status of post with required condtions for any custom post type.

For example if we want to hide status for some post type, then we can hide by using following code.


function wp_hide_status( $status, $post, $column_name, $mode ) {
    
    //Get the post type. Replace YOUR_CPT with your CPT slug.
    if ( $post->post_type == 'YOUR_CPT' ) {
        return false;
    }
    return $status;
}
add_filter( 'post_date_column_status', 'wp_hide_status', 10, 4);

Parameters

  • $status : (string) The status text.
  • $post : (WP_Post) Post object.
  • $column_name : (string) The column name.
  • $mode : (string) The list display mode (‘excerpt’ or ‘list’).

Live Example

To run the hook, copy the example below.

$status = apply_filters( 'post_date_column_status', $status, $post, $date, $mode ); 
                         
if ( !empty( $status ) ) { 
                         
   // everything has led up to this point... 
                         
} 
  

The following example is for adding a hook callback.

add_filter( 'post_date_column_status', 'wp_post_date_column_status_filter', 10, 4 );


function wp_post_date_column_status_filter( $status, $post, $column_name, $mode ){

	// filter...
	return $status;
}

To remove a hook callback, use the example below.


// remove the filter 
remove_filter( 'post_date_column_status', 'wp_post_date_column_status_filter', 10, 4 ); 

  

Explore the latest in WordPress

Trying to stay on top of it all? Get the best tools, resources and inspiration sent to your inbox every Wednesday.