I have the following code set up to display a column on my post list, wanting to display the values from a custom field I have set up called "cook_time".
function cust_field_text($column_name){
if($column_name === 'cust_col'){
get_post_meta( $post_id, 'cook_time', true );
}
}
add_action('manage_posts_custom_column', 'cust_field_text', 10, 2);
function cust_fields($column){
$column['cust_col'] = __('Cook Time');
return $column;
}
add_filter('manage_posts_columns', 'cust_fields');
The column is appearing with the title "Cook Time," as it should. But the column is empty. When I replace "get_post_meta( $post_id, 'cook_time', true );" with "the_meta();" the column fills with all of the custom fields of the post, including their key and value.
I just want the value of the specific field called "cook_time," which is a custom field in my product postings in WooCommerce. I have tried replacing "$post_id" with "$product_id" and "$product->id", neither of those work either.
What am I doing wrong?