Code-Snippets-Functions/Execute a function on a child site/Easy Digital Downloads/display-purchase-button-on-download-archives.txt

15 lines
611 B
Text

// remove original filter that adds purchase button below download content
remove_filter( 'the_content', 'edd_after_download_content' );
// add adjusted filter that includes "is_archive()"
function custom_edd_after_download_content( $content ) {
global $post;
if ( $post && $post->post_type == 'download' && ( is_singular( 'download' ) || is_archive( 'download' ) ) && is_main_query() && !post_password_required() ) {
ob_start();
do_action( 'edd_after_download_content', $post->ID );
$content .= ob_get_clean();
}
return $content;
}
add_filter( 'the_content', 'custom_edd_after_download_content' );