Support » Plugins » [Plugin: Audio Player] accessing audioplayer with do_shortcode() only printing text

  • Resolved gojsse

    (@gojsse)


    I have a custom field, we’ll call it cd_mp3_1 and I have applied a track name to it. We’ll call it Voices.mp3

    I can do [audio: Voices.mp3] in the associated post editor and it displays the player fine (meaning everything else like the audio directory is setup correctly)

    I wish to access this custom field in a category template I created to display CDs of a certain musician and display the player – to automate things via a CMS. I read a lot about shortcode lately and this is what people are saying to do within the category template:

    echo do_shortcode('[audio: Voices.mp3]');

    However, it just prints the text – [audio: Voices.mp3]

    I wish to eventually do this:

    //get the custom field value from this post and key cd_mp3_1
    $temp = get_post_meta ($post->ID, 'cd_mp3_1', true);
    //pass $temp as argument of function do_shortcode
    echo do_shortcode($temp);

    this is my first post ever so I hope I did the backticks correctly where needed when showing code examples

    http://wordpress.org/extend/plugins/audio-player/

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter gojsse

    (@gojsse)

    oops,

    Ok, so that last bit of code on my post should be

    //get the custom field value from this post and key cd_mp3_1
    $temp = get_post_meta ($post->ID, 'cd_mp3_1', true);
    $shortcode_temp = "[audio: '".$temp."']";
    //pass $shortcode_temp as argument of function do_shortcode
    echo do_shortcode($shortcode_temp);

    assuming the user simply input Voices.mp3 into the custom field called cd_mp3_1 instead of the full shortcode. I’d like to keep all code out of the custom fields as much as possible to simplify things for the user.

    also, I tried echo do_shortcode('[gigpress_archive]');
    to makes sure I was doing everything right and the gigpress plugin shortcode output correctly on my category template.

    SOLVED!
    I have had the same problem and after digging in the code I found out that audio player doesn’t use the usual shortcode functionality. Instead it uses regular expressions.

    So kept digging and I found an experimental code inside the plugin.

    function insert_audio_player($source) {
    	global $AudioPlayer;
    	echo $AudioPlayer->processContent($source);
    }

    so use this
    insert_audio_player('[gigpress_archive]'); inside your template.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘[Plugin: Audio Player] accessing audioplayer with do_shortcode() only printing text’ is closed to new replies.