Skip to main content

benecaster_feed_sync_should_import

Filter Free

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.

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. 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 →