I need enhance RSS Atom feed for correct enclosure informations of post attachements.
For example:
Post https://www.kremnica.sk/2018/04/11/zmeny-a-doplnky-c-3-uzemneho-planu-mesta-kremnica/ include one href pdf in body:
https://www.kremnica.sk/wp-content/uploads/2018/04/Strategicky_dokument_ZaD_c_3.pdf
I need that this pdf link will be enclosured in RSS Atom feed.
Posts can contain more than one pdf in body, and other attachement for too (images jpg, png, word documents etc.)
How can I grab this informations into RSS enclosure?
RSS enclosure example:
<item>
<guid isPermaLink="false">https://mesto.sk/clanok/rozhodnutie-uradu</guid>
<link>https://mesto.sk/clanok/rozhodnutie-uradu</link>
<author>[email protected]</author>
<title>Rozhodnutie uradu</title>
<description>Toto je rozhodnutie úradu o pou?ívaní priestranstva</description>
<enclosure url="https://mesto.sk/files/application/pdf/Rozhodnutie_41.pdf" type="application/pdf" length="1000"/>
<pubDate>2007-03-16T23:00:59Z</pubDate>
<category>frontpage</category>
</item>
I was found this:
https://www.sitekickr.com/snippets/wordpress/add-image-media-content-enclosure-tags-rss
but this is only for images, I need code for all possible types of attachements
]]>It’s simply an atom:link element with the appropriate attributes. The example in the above link needs to be translated to XML format. For example:
<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="https://www.w3.org/2005/Atom">
...
<entry>
...
<link rel="enclosure"
href="https://www.foo.com/bar.pdf"
length="12216320"
type="application/pdf"
hreflang="en" />
<link rel="enclosure" ..... />
...
]]>
thank you for reply. Sorry for no exact terms. I need this for partners website which agregate my feed and displaying it
The wish have “Atom” feed with exact content and enclosured info′s
My feed is
https://www.kremnica.sk/category/oznamy/feed/atom
and pdf′s are not linked as rel=”enclosure”
other rss readers can obtain pdf links from my feed correctly, but partner website no, because they need have <link rel=”enclosure” type=”application/pdf” in feed :
https://i.imgur.com/glw5uoZ.png
https://i.imgur.com/vI7Pxyv.png
for that I need customise ATOM feed for inserting <link rel=”enclosure” type=”application/pdf” correctly
]]>To protect your file from being deleted during theme updates, create a child theme or plugin to contain the template. Any other custom work can go in the same place. If you use a plugin, get_template_part() in the example only works for theme templates. Use load_template() or require() for templates in a plugin folder.
]]>