benecaster_feed_sync_should_import
Filters whether a specific RSS item should be imported as a draft. Return false to skip. Use to filter out trailers, bonus episodes, or episodes matching specific criteria.
Skip importing trailer episodes during feed sync
Feed Sync re-scans the source feed and drafts anything whose GUID isn’t already on the show. When the old host keeps a permanent trailer at the top of the feed, that trailer is otherwise drafted on every sync. Return false from benecaster_feed_sync_should_import to skip items whose <itunes:episodeType> is trailer.
Return false and no draft is created, and nothing is logged — the item still counts in the run’s episodes_new but not in drafts_created, and it’s offered to the filter again on the next sync. Feed Sync only: the setup wizard’s one-time import runs no filters, so a trailer imported that way still arrives as a draft.
<?php
add_filter(
'benecaster_feed_sync_should_import',
function ( bool $should_import, SimpleXMLElement $rss_item, int $show_id ): bool {
if ( ! $should_import ) {
return false;
}
$itunes = $rss_item->children( 'http://www.itunes.com/dtds/podcast-1.0.dtd' );
$type = strtolower( trim( (string) ( $itunes->episodeType ?? '' ) ) );
return 'trailer' !== $type;
},
10,
3
);
Return a boolean. Cast with (bool); the default is true.
⚠ $rss_item is a SimpleXMLElement, not an array. Typing the parameter as array fatals before the callback body runs — a mistake that reached three published recipes and was corrected on 2026-09-15. Read a namespaced child with $rss_item->children( $ns ), and cast to (string) before comparing.
⚠ A skipped item is recorded as SEEN, not as missing. Returning false adds the item’s GUID to the seen list before continue, so the episode is not imported and is not treated as deleted from the source feed on that run. A callback that later stops skipping it will import it then; it is not permanently suppressed.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
$should_import |
bool |
— | Whether to import this RSS item |
$rss_item |
SimpleXMLElement |
— | The RSS item being evaluated |
$show_id |
int |
— | ID of the show |
Returns:
bool
Example
add_filter( 'benecaster_feed_sync_should_import', function( $should_import, $rss_item, $show_id ) {
// Skip any RSS item whose title contains '[trailer]' (case-insensitive).
$title = (string) $rss_item->title;
if ( stripos( $title, '[trailer]' ) !== false ) {
return false;
}
return $should_import;
}, 10, 3 );
Need this built rather than just documented? See our services →