want to add download button on [audio] short code
-
I will try to add download button into wp_audio_shortcode() function using filters. but the download button is outside of html output. In my site i want to hide auio player fault it will show after a text click . that’s why I need download button inside html output mark up . I will share my code right now.
add_filter( 'wp_audio_shortcode', 'ast_audio_shortcode_enhancer', 10, 5 ); function ast_audio_shortcode_enhancer( $html, $atts, $audio, $post_id, $library, $content ) { $audio_types = array( 'mp3', 'ogg', 'wma', 'm4a', 'wav' ); // Use the first audio type that has data. foreach ( $audio_types as $extension ) { if ( strlen( $atts[ $extension ] ) ) { $html .= sprintf( ' <p class="download-file"><a href="%s">Download</a></p> ',$atts[ $extension ] ); break; } } // Otherwise return the original html. return $html; }
here is the output screenshot click here
The page I need help with: [log in to see the link]
Viewing 5 replies - 1 through 5 (of 5 total)
Viewing 5 replies - 1 through 5 (of 5 total)
- The topic ‘want to add download button on [audio] short code’ is closed to new replies.