Forums

Custom Fields - parsing audioplayer (5 posts)

  1. userbraindamage
    Member
    Posted 3 years ago #

    Hi, hope this is in the right section.

    I've started using custom fields (www.kidcapricious.com). They're being used as add-ons to posts to provide image/tweet/link etc of the day.

    I use the 'audioplayer' plugin to embed MP3's sometimes, and some days I'd like to append a track to my post. However I'd like it to appear in a custom field.

    Usually, if [audio:xxx.mp3] is included in the main body content it gets processed and replaced with the audioplayer. This doesn't happen within the custom field.

    Any idea how I can make this happen?

    Many thanks!

    C.

  2. MichaelH
    Volunteer
    Posted 3 years ago #

    Could look at using something like this:

    <?php
    $custom_field_key='whatever your custom field key is';
    $myshortcode = get_post_meta($post->ID, $custom_field_key, true);
    do_shortcode($myshortcode);
    ?>
  3. userbraindamage
    Member
    Posted 3 years ago #

    Thanks for the response Michael.

    If you don't mind - I can't get my head round the logic of that.
    Could you explain?

  4. MichaelH
    Volunteer
    Posted 3 years ago #

    Assuming we are talking about shortcodes that execute your player:

    assign your custom field key name (here you put your custom field key)

    get the custom field value for that key for that post

    execute the shortcode

  5. userbraindamage
    Member
    Posted 3 years ago #

    Ok - I see. A bit slow today.

    Will give it a try, cheers!

Topic Closed

This topic has been closed to new replies.

About this Topic