Created
May 4, 2020 11:56
-
-
Save wowthemesnet/37e89c5dd580e6887264d15bd6cdff23 to your computer and use it in GitHub Desktop.
Getting download link from EDD store using URL variable
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function add_query_vars_filter( $vars ){ | |
$vars[] = "item"; | |
return $vars; | |
} | |
add_filter( 'query_vars', 'add_query_vars_filter' ); | |
get_query_var('item'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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