why get_post_meta is returning 0?

I’m trying to show all the posts on a page with an audio player in it and for that I’m looping through posts in the following manner:


$posts = get_posts();
foreach( $posts as $item)
global $post;
$post_id = $item->ID;
$file_id = get_post_meta($post_id, ‘sound_s’, true);
$file_url = wp_get_attachment_url( $file_id );
$attr = array(
‘src’ => $file_url,
‘loop’ => ”,
‘autoplay’ => ”,
‘preload’ => ‘none’
echo wp_audio_shortcode( $attr );

$ID = $file_id;


But trying to echo or var_dump $file_id is returning in null due to which my audio player can not be shown. And yeah there’s no mistake in meta key and $post_id is also returning currect value. So please tell me why is this happening?

Read more here:: why get_post_meta is returning 0?

Leave a Reply

Your email address will not be published. Required fields are marked *