How do I extract values from custom tags in feedzy
📝Note: This Premium feature is available only with the Developer and Agency plans. If you've already purchased one of the two plans you need to have both the Lite & Pro versions of the plugin activated for the feature to work.
The plugin imports fields such as title, content, and so on. What if you want to fetch a custom tag's value such as date updated or rating? This tutorial shows you how to do it.
Let's extract an XML file from where we need to extract values.
<?xml version="1.0" encoding="UTF-8"?> <feed xmlns="http://www.w3.org/2005/Atom" xmlns:media="http://search.yahoo.com/mrss/" xmlns:yt="http://www.youtube.com/xml/schemas/2015"> <link rel="self" href="http://www.youtube.com/feeds/videos.xml?channel_id=UCBcRF18a7Qf58cCRy5xuWwQ" /> <id>yt:channel:UCBcRF18a7Qf58cCRy5xuWwQ</id> <yt:channelId>UCBcRF18a7Qf58cCRy5xuWwQ</yt:channelId> <title>L2inc</title> <link rel="alternate" href="https://www.youtube.com/channel/UCBcRF18a7Qf58cCRy5xuWwQ" /> <author> <name>L2inc</name> <uri>https://www.youtube.com/channel/UCBcRF18a7Qf58cCRy5xuWwQ</uri> </author> <published>2012-04-04T12:38:47+00:00</published> <entry> <id>yt:video:vMh_QPKGr1Y</id> <yt:videoId>vMh_QPKGr1Y</yt:videoId> <yt:channelId>UCBcRF18a7Qf58cCRy5xuWwQ</yt:channelId> <title>Nobel Prize Economics in 6 Minutes</title> <link rel="alternate" href="https://www.youtube.com/watch?v=vMh_QPKGr1Y" /> <author> <name>L2inc</name> <uri>https://www.youtube.com/channel/UCBcRF18a7Qf58cCRy5xuWwQ</uri> </author> <published>2018-12-13T21:17:56+00:00</published> <updated>2018-12-15T13:44:59+00:00</updated> <media:group> <media:title>Nobel Prize Economics in 6 Minutes</media:title> <media:content url="https://www.youtube.com/v/vMh_QPKGr1Y?version=3" type="application/x-shockwave-flash" width="640" height="390" /> <media:thumbnail url="https://i3.ytimg.com/vi/vMh_QPKGr1Y/hqdefault.jpg" width="480" height="360" /> <media:description>Nobel Prize-winning economist Paul Romer explains how ideas translate into growth. Episode 197</media:description> <media:community> <media:starRating count="873" average="4.89" min="1" max="5" /> <media:statistics views="20579" /> </media:community> </media:group> </entry> <entry> <id>yt:video:vTutsbudlBI</id> <yt:videoId>vTutsbudlBI</yt:videoId> <yt:channelId>UCBcRF18a7Qf58cCRy5xuWwQ</yt:channelId> ...<br>
You can achieve it depending on how you are importing the posts:
🛠 Extract price using the shortcode
Follow the table below to understand how to provide the value of the mapping attribute of the shortcode:
Element/Attribute | Value of 'mapping' attribute | Extracted value |
Feed level element | ||
<title> | price=feed|title | L2inc |
<yt:channelId> | price=feed|yt:channelId | UCBcRF18a7Qf58cCRy5xuWwQ |
Item level element (each item will correspond to one element, so we will assume this is the first item) |
||
<updated> | price=updated | 2018-12-15T12:09:11+00:00 |
<media:title> | price=media:title | Nobel Prize Economics in 6 Minutes |
<media:starRating> / average | price=media:starRating@average | 4.88 |
Examples
[feedzy-rss feeds="https://themeisle.com/blog/feed/" price="yes" template="style1" mapping="price=pubDate"]
[feedzy-rss feeds="https://themeisle.com/blog/feed/" price="yes" template="style1" mapping="price=feed|title"]
📝 Feed to Post
Follow the table below to understand the format of the magic tags that you can use.
Element/Attribute | Tag | Extracted value |
Feed level element | ||
<title> | [#feed_custom_title] | L2inc |
<yt:channelId> | [#feed_custom_yt:channelId] | UCBcRF18a7Qf58cCRy5xuWwQ |
Item level element (each post will correspond to one element, so we will assume this is the first post) |
||
<updated> | [#item_custom_updated] | 2018-12-15T12:09:11+00:00 |
<media:title> | [#item_custom_media:title] | Nobel Prize Economics in 6 Minutes |
<media:starRating> / average | [#item_custom_media:starRating@average] | 4.88 |
Let's try to import the average rating field using the above table. We want to fetch this average rating:
- 1
-
Add a new import feed with the URL https://www.youtube.com/feeds/videos.xml?channel_id=UCBcRF18a7Qf58cCRy5xuWwQ.
- 2
-
Configure the filters of the feed to get the desired results.
- 3
-
In the Map Content area > Advanced Options, make sure you create a custom field as follows:
You can also add the tag [#item_custom_media:starRating@average] in the " Item Content" field in the General tab of the Map Content.
💡Result
Output Where Item Content field is showing the Average rating:
It will create a new custom field named "Average Rating" and fetch the rating value in it.
📝 Note: Gutenberg/Block Editor doesn't have custom fields enabled by default. If you don't see the above screen, enable them by using these steps.
Extracting a subset of items or the Nth element only
In the following example, we'll use a source with multiple creators on each post( click to see the full source).
<?xml version='1.0' encoding='UTF-8'?> <rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/" version="2.0"> <channel> <title>RCIGM Publications</title> <link>https://pubmed.ncbi.nlm.nih.gov/rss-feed/?feed_id=1854v2hhZnt_mhFdDPyD32xkxaSsIVGKhpnUhzqvOF03NQ8Ic3&ff=20210924094051&utm_medium=rss&utm_content=1854v2hhZnt_mhFdDPyD32xkxaSsIVGKhpnUhzqvOF03NQ8Ic3&fc=20210322141756&utm_source=Chrome&utm_campaign=pubmed-2&v=2.15.0</link> <description>RCIGM Publications: Latest results from PubMed</description> <atom:link href="https://pubmed.ncbi.nlm.nih.gov/rss-feed/?feed_id=1854v2hhZnt_mhFdDPyD32xkxaSsIVGKhpnUhzqvOF03NQ8Ic3&ff=20210924094051&utm_medium=rss&utm_content=1854v2hhZnt_mhFdDPyD32xkxaSsIVGKhpnUhzqvOF03NQ8Ic3&fc=20210322141756&utm_source=Chrome&utm_campaign=pubmed-2&v=2.15.0" rel="self"/> <docs>http://www.rssboard.org/rss-specification</docs> <generator>PubMed RSS feeds (2.15.0)</generator> <language>en</language> <lastBuildDate>Fri, 24 Sep 2021 13:40:53 +0000</lastBuildDate> <pubDate>Tue, 21 Sep 2021 06:00:00 -0400</pubDate> <ttl>120</ttl> <item> <title>Insights into the expanding phenotypic spectrum of inherited disorders of biogenic amines</title> <link>https://pubmed.ncbi.nlm.nih.gov/34545092/?utm_source=Chrome&utm_medium=rss&utm_campaign=pubmed-2&utm_content=1854v2hhZnt_mhFdDPyD32xkxaSsIVGKhpnUhzqvOF03NQ8Ic3&fc=20210322141756&ff=20210924094051&v=2.15.0</link> <description>Inherited disorders of neurotransmitter metabolism are rare neurodevelopmental diseases presenting with movement disorders and global developmental delay. This study presents the results of the first standardized deep phenotyping approach and describes the clinical and biochemical presentation at disease onset as well as diagnostic approaches of 275 patients from the registry of the International Working Group on Neurotransmitter related Disorders. The results reveal an increased rate of...</description> <content:encoded>...</content:encoded> <guid isPermaLink="false">pubmed:34545092</guid> <pubDate>Tue, 21 Sep 2021 06:00:00 -0400</pubDate> <dc:creator>Elijah H Bolin</dc:creator> <dc:creator>Yevgeniya Gokun</dc:creator> <dc:creator>Paul A Romitti</dc:creator> <dc:creator>Sarah C Tinker</dc:creator> <dc:creator>April D Summers</dc:creator> <dc:creator>Paula K Roberson</dc:creator> <dc:creator>Charlotte A Hobbs</dc:creator> <dc:creator>Sadia Malik</dc:creator> <dc:creator>Lorenzo D Botto</dc:creator> <dc:creator>Wendy N Nembhard</dc:creator> <dc:creator>National Birth Defects Prevention Study</dc:creator> . . .
In the following examples, you can see how the magic tags were used in the import wizard and the output result.
The default case - the plugin will extract only the first item:
[#item_custom_dc:creator]
Elijah H Bolin
Example 1 - extracting only the third item
[#item_custom_dc:creator[3]]
Paul A Romitti
Example 2 - extracting the second, fourth, and sixth items
[#item_custom_dc:creator[2]][#item_custom_dc:creator[4]][#item_custom_dc:creator[6]]
Yevgeniya Gokun Sarah C Tinker Paula K Roberson