Edit Post Author Name in WordPress Feeds

Just today someone approached me at work about the author’s name displaying in Google search results instead of our company name. You can change what shows for each individual author in the your profile for WordPress, but if you want to keep it all the same regardless of who posted the article (useful for a business), you can use the following code as an example:

What’s Going On in this Code?

The first thing we are doing is using an action in the feed file to set a global variable that says we are currently in the feed.

Note: WordPress offers different types of feeds, so you may want to perform this for each of them. If you look in your wp-includes/ folder, you should see some files that begin with “feeds-“. Each of these has their own hook you can use to create the global variable (as done above in the my_rss2_ns function). I’ve listed the file and the hooks below:

File Hook
wp-includes/feeds-rdp.php rdf_ns
wp-includes/feeds-rss.php rss_ns
wp-includes/feeds-rss2.php rss2_ns

The last thing we are doing is simply checking if our global variable is true, and if so, updating the author text with something we’ve specified.

You may also like...