wordpress get url from meta_key value

0

I would like to get the separate value url placed in meta_key

I have a custom field "Custom file" called mp3 ai put the mp3 multiple fields would like to get url of each value

This code below shows the url only of the last mp3 added

<?php $minha_variavel = get_post_meta($post->ID, 'mp3', true); ?>

<?php if ($minha_variavel): ?>
<?php echo wp_get_attachment_url($minha_variavel); ?>
<?php endif; ?>
    
asked by anonymous 04.03.2016 / 07:10

1 answer

0

Adding what colleagues commented on your question would look like this:

$minha_variavel = get_post_meta($post->ID, 'mp3'); // O terceiro parâmetro é FALSE por padrão

foreach ($minha_variavel as $arquivo) { // Segundo a documentação o retorno é sempre um array
    echo wp_get_attachment_url($arquivo);
}
    
04.03.2016 / 18:05