johnbillion / extended-cpts

A library which provides extended functionality to WordPress custom post types and taxonomies.
GNU General Public License v2.0
980 stars 96 forks source link

Taxonomy admin cols meta_key date_format #191

Open epigeyre opened 2 years ago

epigeyre commented 2 years ago

Hi,

I have an acf field on every term of a custom taxonomy. This ACF field contains a date but when I use

'admin_cols' => array(
    'week_start' => array(
    'title' => 'Date de début',
    'meta_key' => 'week_start',
    'date_format' => 'd/m/Y',
),
)

The date doesn't get formatted correctly. I've check the value returned without the date_format and it's something like 20220214.

Now if I go to extended-cpts/src/TaxonomyAdmin.php and add an strtotime() around the $val on lines 269 and 271 I have no problems. Is there a reason why this is not already the case?

Also, is it possible to make this new column sortable (on the edit-tag screen)?

Thanks for your help!

johnbillion commented 2 years ago

This column type expects either a Unix timestamp or a MySQL datetime string. This might not be documented because to be honest custom columns on taxonomies aren't as frequently used as those on post types.

You can add a function argument and handle the outputting yourself, otherwise this looks like it needs a fix similar to the one in #187 for post types.

Sortable columns aren't yet supported for taxonomies.