get_post_meta return empty string
- by Jean-philippe Emond
I guest it is a little issues but
I running a SQL to get some post id.
$result = $wpdb->get_results("SELECT wppm.post_id FROM wp_postmeta wppm INNER JOIN wp_posts wpp ON wppm.post_id=wpp.ID WHERE wppm.meta_key LIKE 'activity'");
(count: 302)
After that, I get all id and I run get_post_meta like that:
foreach($result as $id){
$activity = get_post_meta($id);
var_dump($activity);
foreach($activity as $key=>$value){
if(is_array($value) && $key=="age"){
var_dump($value);
}
}
}
(var_dump result: string "")
samething if I run with:
$activity = get_post_meta($id,'activity',true);
Where we need to get a result.
What is wrong?
Thank you for your help!!!
[Bonus Question]
If the "activity" meta_key as an array Value. and I get directly like:
$result = $wpdb->get_results("SELECT wppm.meta_value FROM wp_postmeta wppm INNER JOIN wp_posts wpp ON wppm.post_id=wpp.ID WHERE wppm.meta_key LIKE 'activity'");
How I parse it?
Thanks again!