Skip to content

Instantly share code, notes, and snippets.

@gboone
Last active February 21, 2019 16:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save gboone/5396a5662aa06ca2340c0a353e26a7aa to your computer and use it in GitHub Desktop.
Save gboone/5396a5662aa06ca2340c0a353e26a7aa to your computer and use it in GitHub Desktop.
A simple jekyll template to generate WordPress eXtended RSS (WRX) feeds suitable for importing into a WordPress site
---
---
<?xml version="1.0" encoding="UTF-8" ?>
<!-- This is a WordPress eXtended RSS file generated by WordPress as an export of your site. -->
<!-- It contains information about your site's posts, pages, comments, categories, and other content. -->
<!-- You may use this file to transfer that content from one site to another. -->
<!-- This file is not intended to serve as a complete backup of your site. -->
<!-- To import this information into a WordPress site follow these steps: -->
<!-- 1. Log in to that site as an administrator. -->
<!-- 2. Go to Tools: Import in the WordPress admin panel. -->
<!-- 3. Install the "WordPress" importer from the list. -->
<!-- 4. Activate & Run Importer. -->
<!-- 5. Upload this file using the form provided on that page. -->
<!-- 6. You will first be asked to map the authors in this export file to users -->
<!-- on the site. For each author, you may choose to map to an -->
<!-- existing user on the site or to create a new user. -->
<!-- 7. WordPress will then import each of the posts, pages, comments, categories, etc. -->
<!-- contained in this file into your site. -->
<!-- generator="WordPress/4.8.1" created="2017-08-21 00:17" -->
<rss version="2.0"
xmlns:excerpt="http://wordpress.org/export/1.2/excerpt/"
xmlns:content="http://purl.org/rss/1.0/modules/content/"
xmlns:wfw="http://wellformedweb.org/CommentAPI/"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:wp="http://wordpress.org/export/1.2/"
>
<channel>
<title>{{ site.title }}</title>
<link>{{ site.baseurl }}</link>
<description>{{ site.description }}</description>
<pubDate>Mon, 21 Aug 2017 00:17:37 +0000</pubDate>
<language>en-US</language>
<wp:wxr_version>1.2</wp:wxr_version>
<wp:base_site_url>{{ site.baseurl }}</wp:base_site_url>
<wp:base_blog_url>{{ site.baseurl }}</wp:base_blog_url>
<wp:author><wp:author_id>1</wp:author_id><wp:author_login><![CDATA[Greg Boone]]></wp:author_login><wp:author_email><![CDATA[boone.greg@gmail.com]]></wp:author_email><wp:author_display_name><![CDATA[Greg Boone]]></wp:author_display_name><wp:author_first_name><![CDATA[]]></wp:author_first_name><wp:author_last_name><![CDATA[]]></wp:author_last_name></wp:author>
<wp:category>
<wp:term_id>1</wp:term_id>
<wp:category_nicename><![CDATA[blog]]></wp:category_nicename>
<wp:category_parent><![CDATA[]]></wp:category_parent>
<wp:cat_name><![CDATA[Blog]]></wp:cat_name>
</wp:category>
{% for page in site.pages %}
<item>
<title>{{ page.title }}</title>
<link>{{ site.baseurl }}{{ page.permalink }}</link>
<pubDate>Tue, 20 Oct 2009 00:00:00 +0000</pubDate>
<dc:creator><![CDATA[Greg Boone]]></dc:creator>
<guid isPermaLink="false">{{ site.baseurl }}/?page_id={{ forloop.index }}</guid>
<description></description>
<content:encoded><![CDATA[{{ page.content | markdownify }}]]></content:encoded>
<excerpt:encoded><![CDATA[]]></excerpt:encoded>
<wp:post_id>{{ forloop.index }}</wp:post_id>
<wp:comment_status><![CDATA[closed]]></wp:comment_status>
<wp:ping_status><![CDATA[open]]></wp:ping_status>
<wp:post_name><![CDATA[ page.name ]]></wp:post_name>
<wp:status><![CDATA[publish]]></wp:status>
<wp:post_parent>0</wp:post_parent>
<wp:menu_order>0</wp:menu_order>
<wp:post_type><![CDATA[page]]></wp:post_type>
<wp:post_password><![CDATA[]]></wp:post_password>
<wp:is_sticky>0</wp:is_sticky>
<wp:postmeta>
<wp:meta_key><![CDATA[_edit_last]]></wp:meta_key>
<wp:meta_value><![CDATA[2]]></wp:meta_value>
</wp:postmeta>
</item>
{% endfor %}{% assign pagect = site.pages | size %}
{% for post in site.posts %}
<item>
<title>{{ post.title | xml_escape }}</title>
<link>{{ site.baseurl }}{{ post.permalink }}</link>
<pubDate>{{ post.date | date_to_rfc822 }}</pubDate>
<dc:creator><![CDATA[Greg Boone]]></dc:creator>
<guid isPermaLink="false">{{ site.baseurl }}/?p={{ forloop.index | plus: pagect}}</guid>
<description></description>
<content:encoded><![CDATA[ {{ post.content | markdownify }}]]></content:encoded>
<excerpt:encoded><![CDATA[]]></excerpt:encoded>
<wp:post_id>{{ forloop.index | plus: pagect }}</wp:post_id>
<wp:post_date><![CDATA[{{ post.date | date: "%Y-%m-%d %T" }}]]></wp:post_date>
<wp:post_date_gmt><![CDATA[{{ post.date |date: "%Y-%m-%d %T" }}]]></wp:post_date_gmt>
<wp:comment_status><![CDATA[closed]]></wp:comment_status>
<wp:ping_status><![CDATA[open]]></wp:ping_status>
<wp:post_name><![CDATA[{{ post.name }}]]></wp:post_name>
<wp:status><![CDATA[publish]]></wp:status>
<wp:post_parent>0</wp:post_parent>
<wp:menu_order>0</wp:menu_order>
<wp:post_type><![CDATA[post]]></wp:post_type>
<wp:post_password><![CDATA[]]></wp:post_password>
<wp:is_sticky>0</wp:is_sticky>
<category domain="category" nicename="blog"><![CDATA[Blog]]></category>
{% for tag in post.tags %}
<category domain="post_tag" nicename="{{ tag }}"><![CDATA[{{ tag }}]]></category>
{% endfor %}{% assign postmeta = post | wpmeta %}
{% for value in postmeta %}
<wp:postmeta>
<wp:meta_key><![CDATA[{{value[0]}}]]></wp:meta_key>
<wp:meta_value><![CDATA[{{value[1]}}]]></wp:meta_value>
</wp:postmeta>
{% endfor %}
</item>
{% endfor %}
</channel>
</rss>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment