Skip to main content

benecaster_outlinks_count_clicks()

Utilities Premium outlinks
benecaster_outlinks_count_clicks( ?int $show_id, ?array $redirect_ids, string $date_from, string $date_to ): array|WP_Error

Counts human clicks (Outlinks’ bot filter applied) on a show’s tracked links between two dates, by link, episode and channel: your own site, podcast apps (through the feed’s show notes), emails, or elsewhere. Sum the rows for any total you need. See List a show’s Outlinks links and count their clicks.

Parameters

Name Type Default Required Description
show_id ?int — Yes The show whose links to count, or null for the site-wide links (those with no show).
redirect_ids ?array — Yes Link ids from benecaster_outlinks_get_redirects(), or null for every link in scope. An empty array counts nothing. An id that is not one of the show's links counts nothing; ids of 0 or below are dropped.
date_from string — Yes The first day counted, a UTC Y-m-d date.
date_to string — Yes The last day counted, a UTC Y-m-d date, inclusive.

Return Value

Type: array|WP_Error

One row per link, episode and channel with at least one human click: [ 'redirect_id' => int, 'episode_id' => ?int, 'referrer_type' => string, 'clicks' => int ], ordered by link, then episode (null first), then channel. referrer_type is page, rss, email or other. episode_id is null when the link named no episode of the show. [] for a show where Outlinks is off or lapsed. A WP_Error benecaster_outlinks_date_invalid (data.field date_from or date_to) for a date that is not a real day or an end before the start, or benecaster_outlinks_redirect_ids_invalid when $redirect_ids is neither an array nor null.

Example

if ( function_exists( 'benecaster_outlinks_count_clicks' ) ) {
    $rows  = benecaster_outlinks_count_clicks( $show_id, $sponsor_redirect_ids, '2026-11-01', '2026-11-30' );
    $total = is_wp_error( $rows ) ? 0 : array_sum( array_column( $rows, 'clicks' ) );
}

Notes

Defined only while Outlinks is switched on for at least one show. Guard with function_exists(). No capability check: the figures are counts with no personal data, but check manage_options (or your own capability) before showing them in answer to a request.

Need this built rather than just documented? See our services →