Skip to content

Instantly share code, notes, and snippets.

@wowthemesnet
Created May 4, 2020 11:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wowthemesnet/37e89c5dd580e6887264d15bd6cdff23 to your computer and use it in GitHub Desktop.
Save wowthemesnet/37e89c5dd580e6887264d15bd6cdff23 to your computer and use it in GitHub Desktop.
Getting download link from EDD store using URL variable
<?php
function add_query_vars_filter( $vars ){
$vars[] = "item";
return $vars;
}
add_filter( 'query_vars', 'add_query_vars_filter' );
get_query_var('item');
<?php
//link should be https://site.com?item=slug
if (get_query_var('item')) {
$download = edd_get_download($item);
$download_id = $download->id;
$files = edd_get_download_files( $download_id );
foreach( $files as $filekey => $file ) { ?>
<a class="btn" href="<?php echo $file['file'];?>">Download <?php echo $file['name'];?></a>
<?php }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment