# Category Name Before Feed Item Titles

> Puts the post's category in front of each title in your feeds, for example "[Recipes] Easy Pancakes", so subscribers can scan topics at a glance.

- Type: PHP
- Runs: Run everywhere
- Category: [RSS Feeds](https://wpide.com/library/category/rss/)
- Tags: feeds, categories, titles
- Author: WPIDE Team
- Installs: 0
- Updated: 2026-10-28
- Page: https://wpide.com/library/category-name-before-feed-titles/

## Code

```php
// Format of the prefix; %s is the category name.
$wpide_feed_title_prefix = '[%s] ';

add_filter( 'the_title_rss', function ( $title ) use ( $wpide_feed_title_prefix ) {
    if ( 'post' !== get_post_type() ) {
        return $title;
    }

    $default = (int) get_option( 'default_category' );

    foreach ( get_the_category() as $category ) {
        if ( (int) $category->term_id !== $default ) {
            return sprintf( $wpide_feed_title_prefix, wp_strip_all_tags( $category->name ) ) . $title;
        }
    }

    return $title;
}, 9 ); // Before WordPress escapes feed titles (priority 10).
```

## Notes

The default "Uncategorized" category is skipped; change the format string to use another style, such as "Recipes: ".

## How to use it

Install the free WPIDE plugin (https://wordpress.org/plugins/wpide/), find "Category Name Before Feed Item Titles" 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/
