Snippets

Merkulove Team Change the post date in the podcast feed using the speaker_podcast_item_raw filter

Created by Dmitry Merkulov
if ( ! function_exists( 'speaker_podcast_item_raw' ) ) {
    /**
     * Replaces [item_date] with the non-translated Post date in the given item.
     *
     * @param string $podcast_item The podcast_item to modify.
     * @return string The modified podcast_item with the non-translated Post date.
     */
    function speaker_podcast_item_raw( string $podcast_item ): string
    {

        // Get the Post ID.
        $post_id = get_the_ID();
        if ( ! $post_id ) { return $podcast_item; }

        // Get the Post.
        $post = get_post( $post_id );
        if ( ! $post ) { return $podcast_item; }

        // Replace [item_date] with the non-translated Post date.
        return str_replace(
            '[item_date]',
            get_post_time( 'l, d F Y H:i:s T', false, $post ),
            $podcast_item
        );

    }
}
add_filter( 'speaker_podcast_item_raw', 'speaker_podcast_item_raw' );

Comments (0)

HTTPS SSH

You can clone a snippet to your computer for local editing. Learn more.