Column filter:
The filter for modifying, removing or adding columns to post list in WordPress admin panel is manage_{$post_type}_posts_columns
. Exchange {$post_type}
with the desired post type. For example; if you want to edit columns for post type 'post'
, the filter name would be manage_post_posts_columns
. And for a custom post type 'product'
, the filter name would be manage_product_posts_columns
.
Column content hook:
The hook for controlling the output of the column content in WordPress admin panel is manage_{$post_type}_posts_custom_column
with the desired post type. For example; if you want to edit columns for post type 'post'
, the filter name would be manage_post_posts_custom_column
.
For your case you need to remove default date column and add your custom column with your local date. See the example code below for 'post'
type.
// manage the columns of the `post` post type
function manage_columns_for_post($columns){
//remove columns
unset($columns['date']);
//add new columns
$columns['local_date'] = 'Local Date';
return $columns;
}
add_action('manage_post_posts_columns','manage_columns_for_post');
// populate custom columns for `post` post type
function populate_post_custom_columns($column,$post_id){
//local date column
if($column == 'local_date'){
// convert date to local by $post_id
echo 'Published <br> 2020/12/12 at 6:30 am'; // dynamically get date of each post and display it
}
}
add_action('manage_post_posts_custom_column','populate_post_custom_columns',10,2);
Hope it will be usefull.