Hi,
I’m trying to get a fields value and label inside a row in a custom column. Everything works fine when no filters are applied, but when I apply the filter nothing is showing up and I don’t know why.
Here is the code sample (a bit modified):
add_filter('manage_cptName_posts_columns' , 'add_cptName_columns', 1);
function add_cptName_columns($columns) {
unset( $columns['date'] );
return array_merge($columns,
[ 'colum_one' => 'Column One' ],
[ 'column_two' => 'Column Two'] ,
[ 'date' => 'Datum unosa' ]
);
}
add_action('manage_cptName_posts_custom_column' , 'cptName_custom_columns', 10, 2 );
function cptName_custom_columns( $column, $post_id ) {
// global $post; // tried both $post_id and $post->ID
switch ( $column ):
case 'column_one':
echo '<pre>' . print_r( get_field_object('field_one', $post_id) , true) . '</pre>';
break;
case 'column_two':
echo '<pre>' . print_r( get_field_object('field_two') , true) . '</pre>';
break;
endswitch;
}
I see that I wrote get_post_object
, instead of get_field_object
. I was thinking of get_field_object
.