WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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


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.