# Sponsor Message Inside Feed Items

> Places a short sponsor or promotion message after the first paragraph of every item in your feeds, where RSS readers and RSS-to-email newsletters will show it.

- Type: PHP
- Runs: Run everywhere
- Category: [RSS Feeds](https://wpide.com/library/category/rss/)
- Tags: feeds, sponsorship, monetization
- Author: WPIDE Team
- Installs: 0
- Updated: 2026-10-28
- Page: https://wpide.com/library/sponsor-message-in-feed-items/

## Code

```php
// Message placed after the first paragraph of each feed item (HTML allowed). Empty = off.
// Example: 'This newsletter is supported by <a href="https://example.com/">Example Co</a>.'
$wpide_feed_message = '';
// Limit to posts in these category slugs; empty = all posts.
$wpide_feed_message_categories = array();

add_filter( 'the_content_feed', function ( $content ) use ( $wpide_feed_message, $wpide_feed_message_categories ) {
    if ( '' === trim( $wpide_feed_message ) || ( $wpide_feed_message_categories && ! in_category( $wpide_feed_message_categories ) ) ) {
        return $content;
    }

    $box = '<p style="padding:12px;border-left:4px solid #ccc;background:#f6f7f7;"><em>' . wp_kses_post( $wpide_feed_message ) . '</em></p>';
    $pos = stripos( $content, '</p>' );

    return false === $pos ? $content . $box : substr_replace( $content, '</p>' . $box, $pos, 4 );
} );
```

## Notes

Nothing is added until you write the message; you can limit it to posts in certain categories.

## How to use it

Install the free WPIDE plugin (https://wordpress.org/plugins/wpide/), find "Sponsor Message Inside Feed Items" in its snippet library and add it in one click; or create a new PHP snippet in WPIDE (or any code snippets plugin) and paste the code above. More snippets: https://wpide.com/library/
