Reputation: 45
I am using the following code in my template file to display an audio player with Download Button (download button handled by the audio player plugin)
I need the Post Name To be inserted into the code so that the resulting downloaded filename will match the post name.
example - Post Name = "Really Cool Audio" would = Really Cool Audio.mp3 when Downloaded
It also appears that spaces are being removed even though spaces in .mp3 files are "ok" and preferred.
<?php $customField = get_post_custom_values("audio");
if (isset($customField[0])) {
echo '<h3><a href="'.$customField[0].'" class="button">Need Post Name Here</a></h3>';
} ?>
Upvotes: 0
Views: 101
Reputation: 6285
If you're in The Loop (and it sounds like you are), the following should work. "Need Post Name Here" has been replaced by .get_the_title().
<?php
$customField = get_post_custom_values("audio");
if (isset($customField[0])) {
echo '<h3><a href="'.$customField[0].'" class="button">'.get_the_title().'</a></h3>';
}
?>
Upvotes: 1