mycred_count_all_ref_instances

Description

This function returns an associative array of references and their individual counts from the log.

Available since version 1.3.3

Returns

(array) Associative array of references and counts.

Parameters

Param Type Required Description
function mycred_count_all_ref_instances(
$number int Yes

The number of references to return a count for. Use -1 to return all. Defaults to 5.

$order string No

Sorting order. Either Ascending (ASC) or Descending (DESC). Defaults to DESC.

$type string No

Option to filter the count based on a point type. Must be either a point type key or the string all.

) { ... }

Examples

Example 1: Get all references with their count no matter which point type they belong to.

$references = mycred_count_all_ref_instances( -1, 'DESC', 'all' );

if ( ! empty( $references ) ) {
	foreach ( $references as $reference => $count ) {

		echo $reference . ' ' . $count;

	}
}

Example 2: Get the top 10 references for the default point type.

$count = mycred_count_all_ref_instances( 10 );

if ( ! empty( $references ) ) {
	foreach ( $references as $reference => $count ) {

		echo $reference . ' ' . $count;

	}
}