I have blog post in wordpress for audio podcast like
We talk the latest with forward guidance in the Federal Reserve with Wall Street Journal reporter, Jon Hilsenrath.
I want to make a download link also for the above mp3 url.
How to extract the url from the above content?
I tried like the below but it is not working
<div class="banner-text">
<h1><a href="<?php the_permalink(); ?>"><?php echo the_title(); ?></a></h1>
<?php the_content(); ?>
<?php
$content = get_the_content( $more_link_text, $stripteaser );
preg_match_all('#bhttps?://[^s()<>]+(?:([wd]+)|([^[:punct:]s]|/))#', $content, $match);
$match = $match[0];
?>
<div class="banner-download"><a href="<?php echo $match; ?>"><span class="displace">Download</span></a></div>
</div>
Any help ?
Interesting question. My instinct would be to use as much of WordPress’s built in shortcode functionality as possible to do the work. The
get_post_galleries
function seems to do something similar. So something like this seems to do what you want:You might need to refine it depending on how you want to handle it if there are multiple audio shortcodes.