0

I'm trying to customize a WordPress feed. I know that if I modify wp-includes/feed-rss2.php, the feed is modified. But I don't want to modify this file, as it might get overwritten during an upgrade.

I tried copying the file to wp-content/themes/mytheme/feed-rss2.php, but the file seems to be ignored. I found this article on customizing WordPress feeds, but the article is very old and references files that are just dummy files now.

Background: Here's what I'm actually trying to do, in case there is a better way to do it. Our company has a WordPress blog. The copy of the posts could have been written by anybody, but only one of the two marketing guys actually posts on the blog.

I want to overwrite the author attribute in the feed so that they author always displays as "Acme, Inc." instead of showing the marketing guy's name. I've customized the blog pages to do this, but the feed still shows the user name.

I tried changing both marketing guys' usernames to "Acme, Inc.", but they didn't like that because they couldn't tell them apart when they needed to edit posts.

1 Answer 1

3

Feed templates are special case. You can't simply provide your own template - you need to work with do_feed_ hooks to change handler function.

But for your specific question it is much easier to override author. Try this (not tested):

add_filter( 'the_author', 'feed_author' );

function feed_author($name) {

    if( is_feed() )
        return 'Acme, Inc.';

    return $name;
}
1
  • FYI- this code goes in wp-content/themes/mytheme/functions.php. (I was trying to remember where I changed this and it wasn't on the page anywhere.)
    – Kip
    Oct 7, 2011 at 20:13

Your Answer

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

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