Please note: Functionality described on this page requires Download Monitor version 4.0 or above.
Downloads in Download Monitor can be fetched via the Download Repository. Retrieve is a method of Download Monitor’s download repository service. The method returns an array of downloads. Modifiable with filters. Can be limited and offset.
Signature
public function retrieve( $filters=array(), $limit=0, $offset=0 );
Parameters
Parameter | Type | Default | Description |
---|---|---|---|
$filters | array | array() | The filters that set what downloads will be fetch. Basic WP_Query parameters can be used here with some exceptions. Ignored parameters are post_type , posts_per_page , offset , paged , nopaging . |
$limit | int | 0 | Allows you to limit the amount of downloads that are fetched. |
$offset | int | 0 | The offset specifies the offset of the first row to return. Allows you to skip given offset of downloads in the result set. |
Examples
Retrieve all downloads
This snippet retrieves all published downloads.
$downloads = download_monitor()->service( 'download_repository' )->retrieve();
Retrieve all downloads, order by title
This snippet retrieves all published downloads but order them by title.
$downloads = download_monitor()->service( 'download_repository' )->retrieve( array(
'orderby' => 'title',
'order' => 'ASC'
) );
Retrieve all downloads of author
This snippet retrieves all published downloads but order them by title.
$downloads = download_monitor()->service( 'download_repository' )->retrieve( array(
'author' => 2
) );
Retrieve all downloads in a category
This snippet retrieves all published downloads but order them by title.
$downloads = download_monitor()->service( 'download_repository' )->retrieve( array(
'tax_query' => array(
array(
'taxonomy' => 'dlm_download_category',
'field' => 'slug',
'terms' => 'my-category-slug'
)
)
) );
Retrieving a single download can also be done with retrieve_single method.