How to Set Up Feed to Post's Custom Field Mapping

Feed to Post's  Custom Field Mapping gives advanced users greater control over what data they can bring into their posts. It is most notably meant for users who import RSS data for use in custom post types, themes or page builder plugins. 

NOTE: This feature requires the use of Custom Fields. Often, these are hidden in the Edit Post screen of your WordPress site.

If you are using the Gutenberg Editor, click on the three dots on the top right of your screen, then click Options and finally check the box for 'Custom Fields' under Advanced Panels.

If you are using the Classic Editor, open the Screen Options drawer from the top-right of the screen and tick the checkbox next to the label “Custom Fields”.

Setting up Custom Field Mapping

We'll explain how to set up custom field mapping with an example. Let's say want to use this YouTube feed for the Best Hip Hop Releases in Australia and extract the data highlighted in the screenshot of the RSS feed below, which is the value of the <yt:channelId> tag, and the <link> tag's href attribute. The href attribute will be extracted for each imported feed item that is converted into a post.

The first step after setting up the feed source under RSS Aggregator > Feed Sources would be to scroll down to the Feed to Post - Custom Field Mapping section and click 'Detect namespaces in Feed Source':

The RSS feed in our example has the following namespaces:

  • Namespace yt with URL: http://www.youtube.com/xml/schemas/2015
  • Namespace media with URL: http://search.yahoo.com/mrss/

The top element in a feed tells you what standard the source is using. <rss> is for RSS 2.0 and <feed> is for Atom. The YouTube feed in our example has <feed> as the top element, so it's using the Atom standard. This top element will have the feed's namespaces declared as attributes, and this YouTube feed has 3 namespaces. They are prefixed with xmlns ("xmlns" is short for XML NameSpace) and the name follows the : colon.

One is xmlns:yt, the second is xmlns:media and the last one has no name, it's just xmlns.
But notice that it still has a URL. Normally, RSS 2.0 feeds do not include the default namespace while Atom feeds include it anyway.

Therefore, this feed needs to use the Atom namespace.

The namespace URL like https://www.youtube.com/xml/schemas/2015 does not need to resolve into anything in particular. This is why it will result in a 404 page when you open this in a browser window. This URL is just an identifier that's unique to the namespace.

Now that we're familiar with namespaces and have detected or identified which namespaces are used by the RSS feed, we can open another browser tab and navigate to RSS Aggregator > Settings > Feed to Post.

There, scroll down to the Custom Namespaces section and set it up like the screenshot below:

Click Save Settings at the bottom of this page.

Notice how we've copied over the name's and URL's that we detected in the Feed to Post - Custom Field Mapping section earlier, plus we're adding details for the atom namespace:

  • Namespace yt with URL: http://www.youtube.com/xml/schemas/2015
  • Namespace media with URL: http://search.yahoo.com/mrss/
  • Namespace atom with URL: http://www.w3.org/2005/Atom

The yt namespace is needed because we are looking for the data in the <yt:channelId> tag. The media namespace will be needed if you want to fetch data from a tag prefixed with media: like <media:title>. The atom namespace is needed because we're looking for the <link> tag's href attribute to show up in the custom meta for the post.

Next, we'll need to refresh the Edit Feed Source page for this feed, and finalize the custom field mapping by setting up the values as in the screenshot below:

For the first entry, choose yt as the namespace, set channelID as the RSS tag, and set channel_id as the custom field placeholder. The custom field placeholder can be any text of your choice. It will be used as the name that identifies the custom field when it's mapped to the imported post.

Similarly, for the second entry, choose atom as the namespace, set link[href] as the RSS tag and set youtube_url as the custom field placeholder. When you save link[href], you are sending an instruction to obtain the href attribute of the <link> RSS tag.

Click Update or Publish at the top right of the Edit Feed Source after setting this up.

Next, re-import your feed if you had already set it up earlier and added the custom field mapping later. This should be done by clicking Delete items and Fetch against the relevant feed source on the RSS Aggregator > Feed Sources page:

Finally, you should be able to see the custom fields mapped to each of your imported posts.

Still need help? Contact Us Contact Us