0

I have this function code, that brings in a ACF date picker data, and adds it to the columns view. It;s raw format is YYYYMMDD

My next step is to change the format of the date to, Day Month Year so it's more legible and if possible have the column sort-able by ascending and descending date.

Probably asking too much, can anyone help? and educate me a bit too :-)

/*
* Add columns to event post list
*/
function add_acf_columns ( $columns ) {
return array_merge ( $columns, array ( 
    'event_date' => __ ( 'Event Date' ),
) );
}
add_filter ( 'manage_events_posts_columns', 'add_acf_columns' );


/*
* Add columns to event event list
*/
function events_custom_column ( $column, $post_id ) {
switch ( $column ) {
  case 'event_date':
   echo get_post_meta ( $post_id, 'event_date', true );
   break;

}
}
add_action ( 'manage_events_posts_custom_column',    'events_custom_column', 10, 2 );
0

Hope this code may be help you

<?php
/*
* Add columns to event post list
*/
function add_acf_columns ( $columns ) {
    return array_merge ( $columns, array ( 
        'event_date' => __ ( 'Event Date' ),
    ));
}
add_filter ( 'manage_events_posts_columns', 'add_acf_columns' );
/*
* Add columns to event event list
*/
function events_custom_column ( $column, $post_id ) {
    switch ( $column ) {
      case 'event_date':
        $event_date = get_post_meta ( $post_id, 'event_date', true );
        echo $fDate = date("d-m-Y", strtotime($event_date));
        break;
    }
}
add_action ( 'manage_events_posts_custom_column',    'events_custom_column', 10, 2 );
?>
  • THis is great thank you so much, is it possible to make the column or orderable? – DJP2019 Mar 5 at 12:18
  • Thank you for your feedback...Are you want column sort-able by ascending and descending date??? right? – Tanmay Patel Mar 5 at 12:24
  • yes is that possible? thanks for you help – DJP2019 Mar 5 at 13:58
  • @darren-pennell I will try to make code as you requested and let you know once it will be done. – Tanmay Patel Mar 5 at 16:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.