Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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>
share|improve this question

1 Answer 1

up vote 2 down vote accepted

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

share|improve this answer
    
thank you for deciphering that nonsense code and my nonsense explanation. –  glu Jun 28 '11 at 4:00

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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