Using WordPress ‘post_date_column_status’ PHP filter

The post_date_column_status WordPress PHP filter allows you to modify the status text of a post.

Usage

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

function your_custom_function($status, $post, $column_name, $mode) {
    // your custom code here
    return $status;
}

Parameters

  • $status (string) – The current status text of the post.
  • $post (WP_Post) – The post object.
  • $column_name (string) – The name of the column where the status text is displayed.
  • $mode (string) – The list display mode (‘excerpt’ or ‘list’).

More information

See WordPress Developer Resources: post_date_column_status

Examples

Change status text color

Change the status text color to green for published posts.

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

function change_status_text_color($status, $post, $column_name, $mode) {
    if ($column_name == 'date' && $post->post_status == 'publish') {
        $status = '<span style="color: green;">' . $status . '</span>';
    }
    return $status;
}

Add custom status text

Display “Featured” status text for posts with a specific meta value.

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

function add_custom_status_text($status, $post, $column_name, $mode) {
    if ($column_name == 'date' && get_post_meta($post->ID, 'featured', true) == 'yes') {
        $status = 'Featured';
    }
    return $status;
}

Change status text for scheduled posts

Modify the status text for scheduled posts to show “Coming Soon”.

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

function change_scheduled_status_text($status, $post, $column_name, $mode) {
    if ($column_name == 'date' && $post->post_status == 'future') {
        $status = 'Coming Soon';
    }
    return $status;
}

Hide status text for draft posts

Remove the status text for draft posts.

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

function hide_draft_status_text($status, $post, $column_name, $mode) {
    if ($column_name == 'date' && $post->post_status == 'draft') {
        $status = '';
    }
    return $status;
}

Append custom text to status

Add ” – Edited” to the status text for all posts.

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

function append_custom_text_to_status($status, $post, $column_name, $mode) {
    if ($column_name == 'date') {
        $status .= ' - Edited';
    }
    return $status;
}