Skip Navigation

[Résolu] Modify columns on "All Items" page

This support ticket is created Il y a 7 années et 5 mois. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Marqué : 

This topic contains 1 réponse, has 1 voix.

Last updated by scottD-2 Il y a 7 années et 5 mois.

Assigned support staff: Ross Fisher.

Auteur
Publications
#325954

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

manage_post_columns

to add a column, but was wondering if this was built in somewhere that I couldn't find?

#326008

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.