functions - ACF Date Form in Custom Admin Field

admin2025-06-02  1

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 );

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 );
Share Improve this question asked Mar 5, 2019 at 11:54 DJP2019DJP2019 33 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 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 );
?>
转载请注明原文地址:http://conceptsofalgorithm.com/Algorithm/1748841302a314169.html

最新回复(0)