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

I have downloaded an audio player plugin for WP. the syntax is very simple. You just add the line [audio:my_file.mp3] to your post editor/excerpt, and call it in the loop with the_content() or the_excerpt() respectively.

I would like to build a metabox in which the user would upload a file, and the plugin syntax would automatically be generated accordingly. I know how to insert the meta-data into the DB, but pulling it with get_post_meta() or the_meta() just gets the syntax as it is, without replacing it with the desired plugin content (i.e the audio player).

I thought about dynamically injecting the syntax to the editor/excerpt with the use of the filter default_content but this filter only applies to normal posts, whereas mine is a custom post type (audio). your ideas are most welcomed.

share|improve this question

Sounds like a custom TinyMCE button would be the ideal candidate for the job.

WordPress has an excellent write-up in the codex on how to create one; you'd essentially add a button to the TinyMCE toolbar with your own callback, which could trigger a modal pop-up to choose the audio file & insert the shortcode automatically.

Equally, you could hook into the output of media items once they've been uploaded, and display a link that would inject the shortcode for that item into the post (if uploaded within the Thickbox pop-up) - akin to how featured thumbnails work.

Check out get_media_item() and get_attachment_fields_to_edit() in wp-admin/includes/media.php for available hooks and filters.

share|improve this answer

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.