Quantcast
Channel: Recent Questions - Stack Overflow
Viewing all articles
Browse latest Browse all 12111

Show advanced custom field value in custom column (wp_list_table)

$
0
0

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

Viewing all articles
Browse latest Browse all 12111

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>