Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save renventura/18255f04769fcdfd1e58 to your computer and use it in GitHub Desktop.
Save renventura/18255f04769fcdfd1e58 to your computer and use it in GitHub Desktop.
Store the content of an Easy Digital Downloads licensed download in a shortcode to use anywhere on your WordPress website.
<?php //* Mind this opening PHP tag
/**
* This snippet creates a shortcode that renders the content of a
* licensed download/product's change log in Easy Digital Downloads.
*
* Example: [edd_changelog download_id="0000"] (replace 0000 with the ID of a download post)
*
* @author Ren Ventura <EngageWP.com>
* @link https://www.engagewp.com/include-easy-digital-downloads-software-licensing-change-logs-posts/
*/
// Change Log Content
add_shortcode( 'edd_changelog', 'edd_changelog_callback' );
function edd_changelog_callback( $atts ) {
// Available attributes
$shortcode_atts = array(
'download_id' => 0,
);
$shortcode_atts = shortcode_atts( $shortcode_atts, $atts );
// Extract each att to a variable
extract( $shortcode_atts );
// Return the changelog data
return get_post_meta( $download_id, '_edd_sl_changelog', true );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment