1. Home
  2. Knowledge Base
  3. Custom Development
  4. Version Repository – retrieve
  1. Home
  2. Knowledge Base
  3. Version Repository
  4. Version Repository – retrieve

Version Repository – retrieve

Please note: Functionality described on this page requires Download Monitor version 4.0 or above.

Versions in Download Monitor can be fetched via the Version Repository. Retrieve is a method of Download Monitor’s version repository service. The method returns an array of versions. Modifiable with filters. Can be limited and offset.

Signature

[wpkb_code lang=”php”]public function retrieve( $filters=array(), $limit=0, $offset=0 );[/wpkb_code]

Parameters

ParameterTypeDefaultDescription
$filtersarrayarray()The filters that set what versions 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.
$limitint0Allows you to limit the amount of versions that are fetched.
$offsetint0The offset specifies the offset of the first row to return. Allows you to skip given offset of versions in the result set.

Examples

Retrieve all versions of Download ID 9

This snippet retrieves all versions for download with ID 11.

[wpkb_code lang=”php”]
$versions = download_monitor()->service( ‘version_repository’ )->retrieve(
array(
‘post_parent’ => 11
)
);
[/wpkb_code]

Retrieve all downloads, order by title

This snippet retrieves the latest version for download with ID 11.

[wpkb_code lang=”php”]
$versions = download_monitor()->service( ‘version_repository’ )->retrieve(
array(
‘post_parent’ => 11
),
1
);
[/wpkb_code]

Retrieving a single version can also be done with retrieve_single method.

Was this article helpful?

Related Articles