Skip to main content

benecaster_ssp_import_post_data

Filter Free migration-wizard Since v1.0.0

Filters the `wp_insert_post()` argument array before each SSP draft episode is inserted. Use to override or supplement the post title, status, content, or date before the record is created.

This filter covers only the core post record — the `post_type`, `post_status`, `post_title`, `post_content`, `post_parent`, `post_date`, and `post_date_gmt` keys. All episode meta fields (audio URL, duration, artwork, and so on) are written separately after insertion and cannot be changed via this filter. To act on the newly created episode after all meta is set, use [benecaster_ssp_episode_imported](/hooks/benecaster_ssp_episode_imported/) instead. The `$ssp_post` parameter provides full access to the original SSP post and its meta — read any SSP-specific field with `get_post_meta( $ssp_post->ID, ‘key’, true )`.

Parameters

Name Type Default Description
$post_data array wp_insert_post() data array built from the SSP post
$ssp_post \WP_Post The original SSP WP_Post being imported
$show_id int ID of the show

Returns: array

Examples

Preserve original SSP publish date

add_filter( 'benecaster_ssp_import_post_data', function( $post_data, $ssp_post, $show_id ) {
    // Preserve the original SSP publish date rather than using today's date.
    $post_data['post_date']     = $ssp_post->post_date;
    $post_data['post_date_gmt'] = $ssp_post->post_date_gmt;
    return $post_data;
}, 10, 3 );

Prepend show name to imported episode titles

add_filter( 'benecaster_ssp_import_post_data', function ( array $post_data, \WP_Post $ssp_post, int $show_id ): array {
    $show_name = get_the_title( $show_id );
    $post_data['post_title'] = $show_name . ': ' . $post_data['post_title'];
    return $post_data;
}, 10, 3 );

Notes

Only the core post record is available here. Episode meta (audio URL, duration, artwork, etc.) is written after insertion and cannot be set via this filter. For post-insertion work on the created episode, use benecaster_ssp_episode_imported.