I wanted to get all the post meta using this code:
$metas = get_post_meta( $post_id, '', true );
The code above will output an array that looks something like:
array(
'sample_key1' => array(
[0] => 'value1'
),
'sample_key2' => array(
[0] => 'value2'
),
'sample_key3' => array(
[0] => 'value3'
)
)
Rather than
array(
'sample_key1' => 'value1',
'sample_key2' => 'value2',
'sample_key3' => 'value3'
)
hence the $single param is true.
It will work when you put a specific key like:
$meta1 = get_post_meta( $post_id, 'sample_meta1' );
will output something like:
array(
[0] => 'value1'
)
and when the $single param is true:
$meta1 = get_post_meta( $post_id, 'sample_meta1', true );
will output something like:
'value1'
I would appreciate any answer I can get.