mirror of
https://gh.wpcy.net/https://github.com/mainwp/Code-Snippets-Functions.git
synced 2026-05-01 11:52:25 +08:00
https://github.com/easydigitaldownloads/library/blob/master/_downloads/display-purchase-button-on-download-archives.html
15 lines
611 B
Text
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' );
|