Pin a featured episode as “latest”
[benecaster_latest_episode] and benecaster_get_latest_episode_id() both resolve through this filter, so one callback changes the shortcode, the function and anything built on either.
Return null to hide the shortcode entirely. An explicit episode_id on the shortcode is not “resolved”, so this filter never overrides one.
Code
<?php
add_filter( 'benecaster_latest_episode_id', function ( ?int $episode_id, int $show_id ): ?int {
$pinned = (int) get_post_meta( $show_id, '_my_featured_episode_id', true );
if ( $pinned && 'publish' === get_post_status( $pinned ) ) {
return $pinned;
}
return $episode_id; // Newest published episode, or null when there is none.
}, 10, 2 );
Hooks Used
Need this built rather than just documented? See our services →