cant access get_post_meta key value

186 views Asked by At

i make some modifications to a results table with woocomerce products, and i want to add some extra information from post meta key unique_code, but it doesnt work as it should be:

$uniquecode = get_post_meta( $post->ID, 'unique_code' , true ); 
$result.='<td>' . $uniquecode. '</td>'; (this result goes in a td)

nothing prints

i also tried this

$mymeta = get_post_meta( $post->ID, 'unique_code', false);

foreach($mymeta as $array) {
    if(isset($array['unique_code'])) {
        $name = $array['unique_code'];
        break;
    }
}

$result.='<td>' . $name . print_r($name ) . '</td>';(this result goes in a td)

the array prints 1.

1

There are 1 answers

0
lenaaxe On

the solution finally was

$key_name = get_post_custom_values($key = 'unique_code');

$result.='' . 'Title: ' . $key_name[0] . '';

:)