Skip to content

Instantly share code, notes, and snippets.

@bekarice
Last active August 29, 2015 14:12
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 bekarice/1c83943387fcc2736ec9 to your computer and use it in GitHub Desktop.
Save bekarice/1c83943387fcc2736ec9 to your computer and use it in GitHub Desktop.
Adds JP sharing buttons after image (if set) or title
/**
* Adds sharing buttons after featured image (if set) or after title (if not)
* Tutorial: http://www.sellwithwp.com/add-social-sharing-buttons-to-easy-digital-downloads/
**/
function add_edd_share_buttons() {
if ( is_singular( 'download' ) && function_exists( 'sharing_display' ) ) {
remove_filter( 'the_content', 'sharing_display', 19 );
remove_filter( 'the_excerpt', 'sharing_display', 19 );
if ( has_post_thumbnail() ) {
add_filter( 'post_thumbnail_html', 'add_share_buttons' );
function add_share_buttons( $thumbnail ) {
echo $thumbnail . sharing_display();
}
} else {
add_action( 'edd_before_download_content', 'add_share_buttons' );
function add_share_buttons() {
echo sharing_display();
}
}
}
}
add_action( 'wp', 'add_edd_share_buttons' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment