How to get all downloads in Easy Digital Downloads

Easy Digital Downloads defaults to using 10 results per page when using the get_products() method. You can modify this default using the edd_api_results_per_page filter.

Here’s how to fetch all products at once:

$EDD_API = new EDD_API;

// Force EDD to show all the downloads at once.
add_filter('edd_api_results_per_page', 'modify_edd_api_results_per_page' );

// Get all the EDD products
$products = $EDD_API->get_products();

// Restore sanity to EDD results per page.
remove_filter('edd_api_results_per_page', 'modify_edd_api_results_per_page' );

/**
* Modify the number of results fetched by EDD
* @param int $per_page Previous results per page setting
* @return int New results per page setting. If you have this many, you're in trouble.
*/
function results_per_page($per_page) {
return 99999999; // Yeah, you've got lots of products!
}

Author: Zack Katz

Zack Katz is the President of Katz Web Services and the developer of WordPress plugins with over 700,000 downloads. He lives in Southwest Colorado with his wife and two cats.

Leave a Reply

Your email address will not be published. Required fields are marked *