Home / Admin / Enable Downloads in the WP REST API
Duplicate Snippet

Embed Snippet on Your Site

Enable Downloads in the WP REST API

Enable the download products to show in the WP REST API

Code Preview
php
<?php
 /**
 * Adds additional arguments into the post type registration for downloads.
 *
 * @param array $download_args The existing array of arguments.
 *
 * @return array
 */
function eddwp_add_rest_for_dls( $download_args ) {
	$download_args['show_in_rest'] = true;
	$download_args['rest_base'] = 'downloads';
	return $download_args;
}
add_filter( 'edd_download_post_type_args', 'eddwp_add_rest_for_dls', 10, 1 );

Comments

Add a Comment