0

I am working with an old system that takes in very specific format for RSS. The one thing that doesn't work is the featured image. I need the image to be in a

<image>
<url></url>
</image>

form but on Wordpress the image always shows in .

Any help here please? Thanks!

1 Answer 1

1

You can use the action rss2_item (and rss_item for RSS 0.92) to output the required tags:

function wpse_406826_rss_featured_image() {
    $src = get_the_post_thumbnail_url( null, 'medium' /* or whatever size you need */ );

    if ( $src ) {
        echo "<image><url>$src</url></image>";
    }
}

add_action( 'rss2_item', 'wpse_406826_rss_featured_image' );
add_action( 'rss_item',  'wpse_406826_rss_featured_image' );

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.