• Resolved AvWijk

    (@avwijk)


    I’m maintaining the website of a choir and I use the Insert Media functionallity to insert MP3 audio to a post.

    As you al know that looks something like this: [audio mp3="https://www.somesite.com/wp-content/uploads/2014/06/FIELDS-OF-GOLD-S1.mp3"][/audio]

    Unfortunately it’s not possible from the front-end to download the track, only to play it. It’s a closed off members-only website and members should be able to download own recorded material, so that covers the whole legal thing.

    Is there any way in functions.php to change this

    [audio mp3="https://www.somesite.com/wp-content/uploads/2014/06/FIELDS-OF-GOLD-S1.mp3"][/audio]

    to this, in an automated way?

    [audio mp3="https://www.somesite.com/wp-content/uploads/2014/06/FIELDS-OF-GOLD-S1.mp3"][/audio]
    <a href="https://www.somesite.com/wp-content/uploads/2014/06/FIELDS-OF-GOLD-S1.mp3">Download FIELDS-OF-GOLD-S1.MP3</a>
Viewing 3 replies - 1 through 3 (of 3 total)
  • Not via the default core shortcode, no. You’d need to look an an mp3 plugin for this.

    Thread Starter AvWijk

    (@avwijk)

    I saw this link, looks perfect, but it’s only for playlists… I need the download link for every single MP3 upload.

    https://wordpress.stackexchange.com/questions/141767/download-button-for-wp-audio-player

    Thread Starter AvWijk

    (@avwijk)

    Solved this.

    I simply list the attached audio files neatly in a table, together with the embedded audio.

    <?php $audio = get_children( array('post_parent' => $post->ID, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'audio' ) ); ?>
                                <?php if ( empty( $audio ) ) : ?>
                                    <?php edit_post_link( '<div class="edit-post">Geen MP3\'s geupload voor deze songtekst.</div>' ); ?>
                                <?php else : ?>
                                    <div>
                                        <p><em>MP3-bestanden voor dit nummer (download / afspelen)</em></p>
                                        <table class="table table-striped">
                                         <tbody>
    
                                        <?php foreach ( $audio as $attachment_id => $attachment ) : ?>
                                            <tr>
    
                                           <td class="col-xs-1"><a style="color: #000;" href="<?php echo wp_get_attachment_url( $attachment_id, 'full' ); ?>"><i class="fa fa-download"></i></a></td>
                                           <td class="col-xs-4"><a style="color: #000; display: block;" href="<?php echo $nummer_url = wp_get_attachment_url( $attachment_id, 'full' ); ?>" title="<?php echo wp_get_attachment_link( $attachment_id, '' , false, false, ' '); ?>" download><?php echo $title = get_the_title( $attachment_id );?>.MP3</a></td>
                                           <td class="col-xs-7"><?php echo do_shortcode('[audio mp3="'.$nummer_url.'"][/audio]'); ?></td>
                                        </tr>
    									<?php endforeach; ?>
    
                                         </tbody>
                                        </table>
                                    </div>
                                <?php endif; ?>
Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Automatically create download link?’ is closed to new replies.