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> 

    1 Answer 1

    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

    1
    • thank you for deciphering that nonsense code and my nonsense explanation.
      – glu
      CommentedJun 28, 2011 at 4:00

    Start asking to get answers

    Find the answer to your question by asking.

    Ask question

    Explore related questions

    See similar questions with these tags.