我会用过滤器wp_audio_shortcode:
/**
* Filter the audio shortcode output.
*
* @since 3.6.0
*
* @param string $html Audio shortcode HTML output.
* @param array $atts Array of audio shortcode attributes.
* @param string $audio Audio file.
* @param int $post_id Post ID.
* @param string $library Media library used for the audio shortcode.
*/
return apply_filters( \'wp_audio_shortcode\', $html, $atts, $audio, $post_id, $library );
似乎$audio不是所述的字符串,而是WP\\u Post类型的对象,因此可以使用$audio->ID来获取元值。
function wpse_163324_audio_filter( $html, $atts, $audio, $post_id, $library ) {
// Use something like
// $meta_values = get_post_meta( $audio->ID, \'your_audio_metas\', true );
// to get the meta values and add them to the var $html like
// $html .= \'<div>your_content</div>\';
return $html;
}
add_filter( \'wp_audio_shortcode\', \'wpse_163324_audio_filter\', 10, 5 );