$conf, $runtime; function_exists('chdir') AND chdir(APP_PATH); $r = 'mysql' == $conf['cache']['type'] ? website_set('runtime', $runtime) : cache_set('runtime', $runtime); } function runtime_truncate() { global $conf; 'mysql' == $conf['cache']['type'] ? website_set('runtime', '') : cache_delete('runtime'); } register_shutdown_function('runtime_save'); ?>functions - ACF Date Form in Custom Admin Field|Programmer puzzle solving
最新消息:Welcome to the puzzle paradise for programmers! Here, a well-designed puzzle awaits you. From code logic puzzles to algorithmic challenges, each level is closely centered on the programmer's expertise and skills. Whether you're a novice programmer or an experienced tech guru, you'll find your own challenges on this site. In the process of solving puzzles, you can not only exercise your thinking skills, but also deepen your understanding and application of programming knowledge. Come to start this puzzle journey full of wisdom and challenges, with many programmers to compete with each other and show your programming wisdom! Translated with DeepL.com (free version)

functions - ACF Date Form in Custom Admin Field

matteradmin9PV0评论

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

Articles related to this article

Post a comment

comment list (0)

  1. No comments so far