Home › Forums › Backend Issues (wp-admin) › adding date to admin columns
I am having problems adding dates to my admin columns
I’ve got it added but the date always shows as “10212016” instead of October 21, 2016.
I have my event_date field set to display and return as “October 21, 2016”
this is my code:
/*
* Add columns to forum post list
*/
function add_acf_columns ( $columns ) {
return array_merge ( $columns, array (
'event_date' => __ ( 'date of event' ),
'event_location' => __ ( 'location' )
) );
}
//add_filter ( 'manage_edit-cr3ativconference_columns', 'add_acf_columns' );
/*
* Add content to forum post list column
*/
function forum_custom_column ( $column, $post_id ) {
switch ( $column ) {
case 'event_date':
echo get_post_meta ( $post_id, 'event_date', true );
break;
case 'event_location':
echo get_post_meta ( $post_id, 'event_location', true );
break;
}
}
add_action ( 'manage_cr3ativconference_posts_custom_column', 'forum_custom_column', 10, 2 );
Hi @rudtek
That’s because you were using the get_post_meta() function instead of the get_field() function. This page should give you more idea about it: https://www.advancedcustomfields.com/resources/displaying-custom-field-values-in-your-theme/. So, you should be able to do it like this:
function forum_custom_column ( $column, $post_id ) {
switch ( $column ) {
case 'event_date':
echo get_field( 'event_date', $post_id );
break;
case 'event_location':
echo get_field( 'event_location', $post_id );
break;
}
}
add_action ( 'manage_cr3ativconference_posts_custom_column', 'forum_custom_column', 10, 2 );
I hope this helps 🙂
is there any way to do with with repeater fields, so i could say load all the speakers who are on that forum post?
Hi @rudtek
For the repeater field, kindly check the documentation here: https://www.advancedcustomfields.com/resources/repeater/.
Thanks 🙂
The topic ‘adding date to admin columns’ is closed to new replies.
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.