Adding a custom image node to a WordPress RSS feed

I’ve been working with a web development firm to update the homepage of my employer’s website. One of the features of the updated homepage is a nicely styled newsfeed that pulls in both news content and the latest posts from our externally hosted WordPress blog. The developers asked me to add a custom node to the RSS feed of the WordPress blog (which I manage) with the featured image URL in it so they could embed that image in a news feed on the homepage. In other words, they wanted me to tweak the RSS feed so it included this bit of markup in each item:


After trying about a dozen plugins off the shelf and poring over many hanging support threads that never resolved the issue, I realized that there isn’t an up-to-date WordPress plugin out there to do this. After consulting the WordPress codex Function Reference and hacking two plugins that get sort of close (SB RSS Feed Plus and Featured Image in RSS), I figured it out. Here I share with you the successful results.

UPDATE: Sage Lichtenwalner has suggested two much better ways to accomplish the same results. The fastest and easiest one is to go to the third link in his comment and copy and paste the image node example code straight into your functions.php file (in your child theme folder, of course).

1. Define a new function that outputs the URL of the post’s featured image.

One way to do this is to append just the function code below (everything from the word “function” to ) to the end of your theme’s functions.php file (which is editable from the theme editor in the WordPress dashboard). A beter way to do this, if you’re using a child theme, is to define the function in a new functions.php file in your child theme main folder. WordPress will append it to the functions defined in the parent theme and in the core of WordPress. Here’s what my functions.php file in my child folder looks like:

< ?php
*Outputs the featured image URL for use in RSS2 feed
    function feed_getFeaturedImage() {
        global $post; if( function_exists ('has_post_thumbnail') && has_post_thumbnail($post->ID)) {
            $thumbnail_id = get_post_thumbnail_id( $post->ID );
            $thumbnail_url = wp_get_attachment_url($thumbnail_id);
        return ($thumbnail_url);

2. Edit your WordPress RSS template (/wp-includes/feed_rss2.php) to include the new node and call the new function you’ve created.

In my case I’m simply going to the paste the following code in feed_rss2.php wherever I want the new node to appear:

<image><?php echo feed_getFeaturedImage(); ?></image>

As it stands, this solution requires the user to customize code (the RSS template) that may get overwritten every time WordPress updates. I would like to figure out a way to do this via plugin or without editing anything but child theme elements. But for now, this does the job.

I don’t know much about PHP, other than that it doesn’t appear to be all that different from the other programming languages I’ve learned. I’m also not a WordPress guru. So I leave it to the WordPress and PHP experts out there to amend my solution with more best practices.

“Where are you *from*?”

By now, you may have already seen this painfully awkward interaction between a white American man and an Asian-American woman.

I found this video hilarious. I’m tempted to start practicing my accents for the next time this exact scenario happens to me. Because it has happened to me, and it will happen to me again.

Yeah, it sometimes makes me and my companions uncomfortable when people ask me fairly clueless questions or make embarrassing assumptions about my ethnic background. No, I don’t appreciate being singled out for unwanted attention based on things that I can’t control, like the color of my skin and the shape of my eyes.

Yeah, I grew up around other kids singing the “ching chong” song at me and pulling the corners of their eyes to make them look narrower.

Yeah, I get the occasional “Konnichiwa” or “Sayonara” from strangers in public places (once from a Swiss French man in an art museum in Geneva – he was surprised and embarrassed when I answered him in French: Bonjour, je suis americaine, je ne parle pas japonais. Americans are not the only people who make assumptions about me based on how I look.) For reasons unknown, I have yet to be greeted in Mandarin or Cantonese.

I try to take these questions in stride. At some point I noticed that when children ask to touch my hair or ask their parents why I look different from other people, I don’t mind answering them at all. We chalk up a child’s behavior to innocence and curiosity. We don’t blame children for not knowing better because they just don’t have the knowledge and experience that adults do.

But adults – adults aren’t allowed to misunderstand or be curious. At some point in our formative years, maybe while we were attending Big City universities, we were supposed to have learned all there is to know about other ethnicities and races and cultures, and we’re embarrassed to admit that we didn’t. Well, some of us are embarrassed.

I say racist things and ask questions that reveal my ignorance and make assumptions about people based on their looks all the time. You do it, too. Imagine you’re walking alone through a dark city alley late at night. You turn a corner and see a big, dark-skinned dude in his 20s in a hooded sweatshirt running at you. How do you react? Replace that man with a petite Asian woman in her 50s in a dress and heels – now how do you react? Whom do you ask for directions in an unfamiliar city – the lone Mexican woman waiting at the bus stop, or the well-dressed young white couple sharing a latte at the corner cafe?

Stereotyping is a form of pattern recognition. We are so very good at seeing patterns that we see them even when they’re not there or don’t apply. Patterns and stereotypes are tools we use to abbreviate the world and make it more manageable – because how exhausting would it be to assess every person we meet anew like they’re the only other person in the world that we’ve ever met? No, we’re wired to assume that most things and living things that look the same, act the same.

Novel things and people are Other. Curiosity about Other is fine and natural. What’s bad and toxic is fear or hatred of Other. I’ll never forget the time I was staying in a hotel in eastern Idaho and I encountered a very conservatively dressed woman and her four children. She positioned herself between me and her children as I walked by, and they all automatically, in unison, averted their eyes. All except the youngest one, who stared me down like an owl.

Compared to that, I’ll take “What kind of Asian are you?” any day.

I wish we would all, at least once, spend some time stranded in the exclusive company of people who look and sound very little or not at all like ourselves. When you are the majority and someone else is the rare bird, you are tuned in to everything “weird” and different about that person. But when become the rare bird, you suddenly find that being different is lonely. You need other people to understand you, not fear you or stereotype you. You search desperately for common needs, desires, wants, which you can use to communicate and connect with these strange people. You find yourself relieved and grateful to meet strangers who are willing and able to communicate with you. You start to adopt many local behaviors and words, words and behaviors which at first seemed odd to you, words and behaviors you may have laughed off if you encountered them in your home country when you were surrounded by Your People. Eventually you make some friends and learn enough of their words and behaviors to not constantly feel awkward in their presence. But still, people openly stare at you in public, make faces at your strange and accented speech, tell jokes you don’t understand.

You get used to playing the role of the Exotic Foreign Person. When you do go home, or at least back to a place where you naturally blend in, you can finally relax. No one picks you out of a crowd and asks to touch your hair, or tries to show off their “knowledge” of your native culture from movies and TV shows.

I’ve lived in times and places where friends and strangers alike were constantly reminding me with their words and actions that You’re Not Like Us. I believed it, and it made me feel lonely. Like they had built a glass cage around me to wall me off from the rest of society.

I’m embarrassed to admit that I secretly carried that cage with me long after I left behind the people who built it.

I didn’t discovered Brooklyn and San Francisco until a few years ago. I was delighted to encounter many other young Asian-American women who spoke accentless English, dressed androgynously and sported visible tattoos and short hair. These were the first places I had been where I felt I could be myself and blend in at the same time. As I walked and trained and bused through those cities I felt shards of glass fall from my invisible cage and shatter at my feet. Other American tourists even stopped me and asked me for directions, and I’d like to think it was because I looked like I belonged there.

Finding those places has helped me embrace and assert my identity. It doesn’t hurt that my identity is becoming more mainstream. For instance, Korean food, and Asian food in general, is everywhere now, and that makes me very happy. My generation is celebrating and embracing diversity of all kinds. I’m no longer offended when people say embarrassingly ignorant things to me or ask questions about my race. I recognize that it is most often an effort to connect and learn rather than blatant racism (Though sometimes the stranger zeroing in on my appearance is a man with an Asian fetish. In which case, I run far, far away as fast as I can.) I enjoy a good opportunity to clear up misunderstandings and address harmful assumptions. I am also aware that for this stranger, I may be the sole real-life representative of an entire category of people. I feel the need to set a positive example.

But always, in the back of my mind, is the memory of what it feels like to be in that cage.