Skip to content

Instantly share code, notes, and snippets.

@X-Raym
Last active May 30, 2016 21:07
Show Gist options
  • Save X-Raym/8ee81ddae418ebe0fccf to your computer and use it in GitHub Desktop.
Save X-Raym/8ee81ddae418ebe0fccf to your computer and use it in GitHub Desktop.
Easy Digital Downloads - Downloads Count Shortcode
<?php
// Optional attributs supported : id, offset
function edd_download_count_shortcode( $atts ) {
$post_id = get_the_ID();
$a = shortcode_atts( array(
'offset' => 0,
'id' => $post_id,
), $atts );
if( function_exists( 'edd_get_download_sales_stats' ) ) {
$download_count = edd_get_download_sales_stats( $a['id'] ) + $a['offset'];
} else {
$download_count = false;
}
return $download_count;
}
add_shortcode( 'edd_download_count', 'edd_download_count_shortcode' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment