When a new CPT is created, the default "All Items" page that lists each post in that post type has basic information, such as Post Title, Author, and Date (published).
You can also add custom fields in the post type setup, which is great, however I would also like to add the automatic expiration date (using CRED) for the post as a column here.
I am using the CPT as a member directory with listings expiring after 1 year. I would like to be able to quickly sort by expiration date so I can follow up with any expired members to get them to renew.
I know it's possible to use something similar to
to add a column, but was wondering if this was built in somewhere that I couldn't find?
In case anyone else is looking for this, I ended up using this code to add the Expiration date column:
//Register Custom Column on Member Admin Page
add_filter('manage_member_posts_columns', 'my_columns');
function my_columns($columns) {
$columns['expiration'] = 'Expiration';
return $columns;
}
add_action('manage_member_posts_custom_column', 'my_show_columns', 10, 2);
function my_show_columns($column, $post_id) {
switch ($column) {
case 'expiration':
$terms = get_post_meta($post_id, '_cred_post_expiration_time', true);
if ($terms) {
echo date("F j Y", $terms);
} else {
echo "No Expiration Set";
}
}
}
It would be nice to be able to add the column through the plugin settings though.