5

This functions at the moment but it only returns the first value from the array. I've been struggling to echo, print, explode, or whatever the multiple custom field values that share the same key (mp3). The shortcode is looking for comma-separated urls aka tracks="http://url1.mp3, http:/url2.mp3" I know i've created a bit of mess here. Wading into deeper waters...

<div id="post_meta_player">
<?
global $post;
if(get_post_meta($post->ID, 'mp3', false))
{
foreach(get_post_meta($post->ID, 'mp3', false) as $mp3)
    {
    $mytracks = print_r($mp3, ',');
    }
}
$shortcodes = '[mp3-jplayer tracks="'.$mytracks.'"]';
mp3j_put( $shortcodes);
?>
</div>
3

Kind of confusing question, but I think you want:

[mp3-jplayer tracks="'.implode(', ', get_post_meta($post->ID, 'mp3', false)).'"]

Assuming you get a array of meta key values this will join the into a comma-separated string

  • thank you for deciphering that nonsense code and my nonsense explanation. – glu Jun 28 '11 at 4:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.