I made a custom post type named address and added values to it with the plugin advanced custom fields. I would like to display those values in a custom column in the wp-list-table.
So I managed to add a column to the custom post type(address) called views. With the code below.
add_filter('manage_edit-address_columns', 'my_columns');
function my_columns($columns) {
$columns['views'] = 'Views';
return $columns;
}
Now I wanted to fill this column (views) with the data from the advanced custom field wich I made and called 'reserveer_url_theater_terra' (it's a url field) and bound to the custom post type address, but it just shows an empty column 'views' without the values from 'reserveer_url_theater_terra' field . What am I doing wrong, could someone point me in the right direction? Should I be using wpdb to get the values? Or is there somthing else I should do? Thank you in advance.
add_action('manage_posts_custom_column', 'my_show_columns');
function my_show_columns($name) {
global $post;
switch ($name) {
case 'views':
$views = get_post_meta($post->ID, 'reserveer_url_theater_terra', true);
echo $views;
}
}
I tried using get_field as Zork suggested, but I still could not get it to work.
$views = get_field('reserveer_url_theater_terra', $post->ID);
add_actionis fired sometime afterinit. ACF api-calls don't work before. 2. Try using get_field() instead of get_post_meta() - zork media