0

I’m trying to use these two template systems (xml templates, php enabled) to export EE (EE core version 2.7) blog entries into WordPress .wxr import format:

These two templates are in a template group called export. One template is called index, and the other is called comments. I open index in a new window and view source to see the .wxr data.

The one template directly below (I was using this before a two template system was suggested) outputs the four blog posts with the status="Home Featured" and all the comments, but the comments don't have the original author or URL but has the admins info, as noted in the original question title.

<rss version="2.0"
    xmlns:excerpt="http://wordpress.org/export/1.1/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.1/"
>

<channel>
    <title>{site_name}</title>
    <link>{site_url}</link>

    <pubDate></pubDate>
    <language>en</language>
    <wp:wxr_version>1.1</wp:wxr_version>
    <wp:base_site_url>http://domain.com/demo1/</wp:base_site_url>
    <wp:base_blog_url>http://domain.com/demo1</wp:base_blog_url>

    <generator>http://wordpress.org/?v=3.1.2</generator>

{exp:channel:entries channel="blog" status="Home Featured" orderby="date" sort="desc" limit="100" offset="0" rdf="off" dynamic="no"} 

    <item>
        <title>{exp:xml_encode}{title}{/exp:xml_encode}</title>
        <link></link>
        <pubDate>{entry_date format="%r"}</pubDate>
        <dc:creator><![CDATA[{author}]]></dc:creator>
        <guid isPermaLink="false">http://domain.com/demo1/?p={entry_id}</guid>
        <description></description>
        <content:encoded><![CDATA[{if blog-body}{blog-body}{if:elseif cc_content}{cc_content}{if:else}{article_content}{/if}]]></content:encoded>
        <excerpt:encoded><![CDATA[{if blog_short}{blog_short}{if:elseif cc_teaser}{cc_teaser}{if:else}{teaser}{/if}]]></excerpt:encoded>
        <wp:post_id></wp:post_id>
        <wp:post_date>{entry_date format="%Y-%m-%d %H:%i:%s"}</wp:post_date>
        <wp:post_date_gmt>{gmt_date format="%Y-%m-%d %H:%i:%s"}</wp:post_date_gmt>
        <wp:comment_status>open</wp:comment_status>
        <wp:ping_status>open</wp:ping_status>
        <wp:post_name>{url_title}</wp:post_name>
        <wp:status>{if status == "open"}publish{if:elseif status == "review"}pending{if:elseif status == "closed"}private{if:elseif status == "draft"}draft{if:else}publish{/if}</wp:status>
        <wp:post_parent>0</wp:post_parent>
        <wp:menu_order>0</wp:menu_order>
        <wp:post_type>post</wp:post_type>
        <wp:post_password></wp:post_password>
        <wp:is_sticky>0</wp:is_sticky>
{categories}
        <category domain="category" nicename="{if category_url_title == "uncategorized"}media{if:else}{category_url_title}{/if}"><![CDATA[{if category_name == "Uncategorized"}Media{if:else}{category_name}{/if}]]></category>
{/categories}
        <wp:postmeta>
            <wp:meta_key>_edit_last</wp:meta_key>
            <wp:meta_value><![CDATA[1]]></wp:meta_value>
        </wp:postmeta>
{if article_links}
        <wp:postmeta>
            <wp:meta_key>Associated Links</wp:meta_key>
            <wp:meta_value><![CDATA[{article_links}]]></wp:meta_value>
        </wp:postmeta>
{/if}
        <wp:postmeta>
            <wp:meta_key>_su_rich_snippet_type</wp:meta_key>
            <wp:meta_value><![CDATA[none]]></wp:meta_value>
        </wp:postmeta>
        <wp:postmeta>
            <wp:meta_key>_encloseme</wp:meta_key>
            <wp:meta_value><![CDATA[1]]></wp:meta_value>
        </wp:postmeta>


{/exp:channel:entries}
{exp:comment:entries sort="desc" entry_id="{embed:entry_id}"}


        <wp:comment>
            <wp:comment_id>{comment_id}</wp:comment_id>
            <wp:comment_author><![CDATA[{name}]]></wp:comment_author>
            <wp:comment_author_email>{email}</wp:comment_author_email>
            <wp:comment_author_url>{url}</wp:comment_author_url>
            <wp:comment_author_IP>{ip_address}</wp:comment_author_IP>
            <wp:comment_date>{comment_date format="%Y-%m-%d %h:%i:%s"}</wp:comment_date>
            <wp:comment_date_gmt>{gmt_comment_date format="%Y-%m-%d %h:%i:%s"}</wp:comment_date_gmt>
            <wp:comment_content><![CDATA[{comment}]]></wp:comment_content>
            <wp:comment_approved>1</wp:comment_approved>
            <wp:comment_type></wp:comment_type>
            <wp:comment_parent>0</wp:comment_parent>
            <wp:comment_user_id>0</wp:comment_user_id>
        </wp:comment>
{/exp:comment:entries}
    </item>
</channel>
</rss>

9/12/13 edit: *This two template system breaks:* index only outputs one blog post and I don't think it correctly passes the blog post info to the comments template (so that the comments are linked by post ID to the blog post) because upon WP import, WP says the author doesn't exist and doesn't import any comments.

"index" template:

     <rss version="2.0"
    xmlns:excerpt="http://wordpress.org/export/1.1/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.1/"
>

<channel>
    <title>{site_name}</title>
    <link>{site_url}</link>

    <pubDate></pubDate>
    <language>en</language>
    <wp:wxr_version>1.1</wp:wxr_version>
    <wp:base_site_url>http://domain.com/demo1/</wp:base_site_url>
    <wp:base_blog_url>http://domain.com/demo1</wp:base_blog_url>

    <generator>http://wordpress.org/?v=3.1.2</generator>

{exp:channel:entries channel="blog" status="Home Featured" orderby="date" sort="desc" limit="10" offset="0" rdf="off" dynamic="no"} 

    <item>
        <title>{exp:xml_encode}{title}{/exp:xml_encode}</title>
        <link></link>
        <pubDate>{entry_date format="%r"}</pubDate>
        <dc:creator><![CDATA[{author}]]></dc:creator>
        <guid isPermaLink="false">http://domain.com/demo1/?p={entry_id}</guid>
        <description></description>
        <content:encoded><![CDATA[{if blog-body}{blog-body}{if:elseif cc_content}{cc_content}{if:else}{article_content}{/if}]]></content:encoded>
        <excerpt:encoded><![CDATA[{if blog_short}{blog_short}{if:elseif cc_teaser}{cc_teaser}{if:else}{teaser}{/if}]]></excerpt:encoded>
        <wp:post_id></wp:post_id>
        <wp:post_date>{entry_date format="%Y-%m-%d %H:%i:%s"}</wp:post_date>
        <wp:post_date_gmt>{gmt_date format="%Y-%m-%d %H:%i:%s"}</wp:post_date_gmt>
        <wp:comment_status>open</wp:comment_status>
        <wp:ping_status>open</wp:ping_status>
        <wp:post_name>{url_title}</wp:post_name>
        <wp:status>{if status == "open"}publish{if:elseif status == "review"}pending{if:elseif status == "closed"}private{if:elseif status == "draft"}draft{if:else}publish{/if}</wp:status>
        <wp:post_parent>0</wp:post_parent>
        <wp:menu_order>0</wp:menu_order>
        <wp:post_type>post</wp:post_type>
        <wp:post_password></wp:post_password>
        <wp:is_sticky>0</wp:is_sticky>
{categories}
        <category domain="category" nicename="{if category_url_title == "uncategorized"}media{if:else}{category_url_title}{/if}"><![CDATA[{if category_name == "Uncategorized"}Media{if:else}{category_name}{/if}]]></category>
{/categories}
        <wp:postmeta>
            <wp:meta_key>_edit_last</wp:meta_key>
            <wp:meta_value><![CDATA[1]]></wp:meta_value>
        </wp:postmeta>
{if article_links}
        <wp:postmeta>
            <wp:meta_key>Associated Links</wp:meta_key>
            <wp:meta_value><![CDATA[{article_links}]]></wp:meta_value>
        </wp:postmeta>
{/if}
        <wp:postmeta>
            <wp:meta_key>_su_rich_snippet_type</wp:meta_key>
            <wp:meta_value><![CDATA[none]]></wp:meta_value>
        </wp:postmeta>
        <wp:postmeta>
            <wp:meta_key>_encloseme</wp:meta_key>
            <wp:meta_value><![CDATA[1]]></wp:meta_value>
        </wp:postmeta>


    {embed="blog/comments" entry_id="{entry_id}"}

{/exp:channel:entries}

    </item>
</channel>
</rss>

"comments" template

<rss version="2.0"
    xmlns:excerpt="http://wordpress.org/export/1.1/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.1/"
>

<channel>
    <title>{site_name}</title>
    <link>{site_url}</link>

    <pubDate></pubDate>
    <language>en</language>
    <wp:wxr_version>1.1</wp:wxr_version>
    <wp:base_site_url>http://domain.com/demo1/</wp:base_site_url>
    <wp:base_blog_url>http://domain.com/demo1</wp:base_blog_url>

    <generator>http://wordpress.org/?v=3.1.2</generator>

{exp:comment:entries sort="desc" entry_id="{embed:entry_id}"}

<item>
        <wp:comment>
            <wp:comment_id>{comment_id}</wp:comment_id>
            <wp:comment_author><![CDATA[{name}]]></wp:comment_author>
            <wp:comment_author_email>{email}</wp:comment_author_email>
            <wp:comment_author_url>{url}</wp:comment_author_url>
            <wp:comment_author_IP>{ip_address}</wp:comment_author_IP>
            <wp:comment_date>{comment_date format="%Y-%m-%d %h:%i:%s"}</wp:comment_date>
            <wp:comment_date_gmt>{gmt_comment_date format="%Y-%m-%d %h:%i:%s"}</wp:comment_date_gmt>
            <wp:comment_content><![CDATA[{comment}]]></wp:comment_content>
            <wp:comment_approved>1</wp:comment_approved>
            <wp:comment_type></wp:comment_type>
            <wp:comment_parent>0</wp:comment_parent>
            <wp:comment_user_id>0</wp:comment_user_id>
        </wp:comment>
</item>
{/exp:comment:entries}
</rss>
3
+25

Saw your post in meta - maybe a new answer which distills the entire thread you and Anna have created will be of help?

You do need two templates. The first will begin your document, and then list each channel entry, and then close the document. Within that template's channel:entries loop, you will embed your "comments" template, which will run once for every entry, and will list all comments for that particular entry, based on the entry_id you pass it via the embed.

So, using your code, the first template looks like this:

<rss version="2.0"
    xmlns:excerpt="http://wordpress.org/export/1.1/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.1/"
>
<channel>
    <title>{site_name}</title>
    <link>{site_url}</link>
    <pubDate></pubDate>
    <language>en</language>
    <wp:wxr_version>1.1</wp:wxr_version>
    <wp:base_site_url>http://domain.com/demo1/</wp:base_site_url>
    <wp:base_blog_url>http://domain.com/demo1</wp:base_blog_url>
    <generator>http://wordpress.org/?v=3.1.2</generator>

{exp:channel:entries channel="blog" status="Home Featured" orderby="date" sort="desc" limit="100" offset="0" rdf="off" dynamic="no"} 
    <item>
        <title>{exp:xml_encode}{title}{/exp:xml_encode}</title>
        <link></link>
        <pubDate>{entry_date format="%r"}</pubDate>
        <dc:creator><![CDATA[{author}]]></dc:creator>
        <guid isPermaLink="false">http://domain.com/demo1/?p={entry_id}</guid>
        <description></description>
        <content:encoded><![CDATA[{if blog-body}{blog-body}{if:elseif cc_content}{cc_content}{if:else}{article_content}{/if}]]></content:encoded>
        <excerpt:encoded><![CDATA[{if blog_short}{blog_short}{if:elseif cc_teaser}{cc_teaser}{if:else}{teaser}{/if}]]></excerpt:encoded>
        <wp:post_id></wp:post_id>
        <wp:post_date>{entry_date format="%Y-%m-%d %H:%i:%s"}</wp:post_date>
        <wp:post_date_gmt>{gmt_date format="%Y-%m-%d %H:%i:%s"}</wp:post_date_gmt>
        <wp:comment_status>open</wp:comment_status>
        <wp:ping_status>open</wp:ping_status>
        <wp:post_name>{url_title}</wp:post_name>
        <wp:status>{if status == "open"}publish{if:elseif status == "review"}pending{if:elseif status == "closed"}private{if:elseif status == "draft"}draft{if:else}publish{/if}</wp:status>
        <wp:post_parent>0</wp:post_parent>
        <wp:menu_order>0</wp:menu_order>
        <wp:post_type>post</wp:post_type>
        <wp:post_password></wp:post_password>
        <wp:is_sticky>0</wp:is_sticky>
{categories}
        <category domain="category" nicename="{if category_url_title == "uncategorized"}media{if:else}{category_url_title}{/if}"><![CDATA[{if category_name == "Uncategorized"}Media{if:else}{category_name}{/if}]]></category>
{/categories}
        <wp:postmeta>
            <wp:meta_key>_edit_last</wp:meta_key>
            <wp:meta_value><![CDATA[1]]></wp:meta_value>
        </wp:postmeta>
{if article_links}
        <wp:postmeta>
            <wp:meta_key>Associated Links</wp:meta_key>
            <wp:meta_value><![CDATA[{article_links}]]></wp:meta_value>
        </wp:postmeta>
{/if}
        <wp:postmeta>
            <wp:meta_key>_su_rich_snippet_type</wp:meta_key>
            <wp:meta_value><![CDATA[none]]></wp:meta_value>
        </wp:postmeta>
        <wp:postmeta>
            <wp:meta_key>_encloseme</wp:meta_key>
            <wp:meta_value><![CDATA[1]]></wp:meta_value>
        </wp:postmeta>
        {embed="blog/comments" entry_id="{entry_id}"}
    </item>
{/exp:channel:entries}
</channel>
</rss>

Then, inside of blog/comments:

{exp:comment:entries sort="desc" entry_id="{embed:entry_id}"}
        <wp:comment>
            <wp:comment_id>{comment_id}</wp:comment_id>
            <wp:comment_author><![CDATA[{name}]]></wp:comment_author>
            <wp:comment_author_email>{email}</wp:comment_author_email>
            <wp:comment_author_url>{url}</wp:comment_author_url>
            <wp:comment_author_IP>{ip_address}</wp:comment_author_IP>
            <wp:comment_date>{comment_date format="%Y-%m-%d %h:%i:%s"}</wp:comment_date>
            <wp:comment_date_gmt>{gmt_comment_date format="%Y-%m-%d %h:%i:%s"}</wp:comment_date_gmt>
            <wp:comment_content><![CDATA[{comment}]]></wp:comment_content>
            <wp:comment_approved>1</wp:comment_approved>
            <wp:comment_type></wp:comment_type>
            <wp:comment_parent>0</wp:comment_parent>
            <wp:comment_user_id>0</wp:comment_user_id>
        </wp:comment>
{/exp:comment:entries}

(The reason the comments chunk needs to be embedded is because there can be variable collisions between the channel:entries tag and the comment:entries tag.)

  • Do both of these templates go in the same template group? And what should each template be named? index and comments, as I have in my question? Right now, I get the posts but not the comments. – markratledge Sep 18 '13 at 2:15
  • My template group is called export and the template file is called index, so the URL I'm viewing and viewing source on is domain.com/export – markratledge Sep 18 '13 at 2:32
  • The location of the templates relative to each other is actually irrelevant, so long as you use the correct embed path for where the comments template is actually located. Also, I see you have channel="blog" status="Home Featured" as channel:entries parameters - is that correct for your setup? – Derek Hogue Sep 18 '13 at 12:09
  • Yes, the channel and status are correct; they result in the post output I want. Posts are showing up in the output, but not comments. What is the correct path to the "comments" template is both templates are in the same template group? – markratledge Sep 18 '13 at 13:47
  • If your template group is called export, and you have placed the comments template inside that group, then the embed path is export/comments. You'll need to change that path in the first template code chunk I posted, near the bottom. – Derek Hogue Sep 18 '13 at 13:49
1

Try adding dynamic="no" to your exp:comment:entries tag. I would also add the channel="" parameter to the tag:

{exp:comment:entries sort="desc" entry_id="{embed:entry_id}" dynamic="no" channel="XXXX"}

Also, confirm that {embed:entry_id} is printing out the correct ID in your embed.


If that doesn't work, make sure your exp:comment:entries is NOT inside a exp:channel:entries tag.


EDIT (September 10, 2013)
Your templates must be setup correctly to get the data you are wanting. From what I think you're trying to do, you need to setup this way with two templates. My code sample below is really dumbed down.

In your first template add the channel:entries tag and add an {embed} tag to a second template to which you pass the entry's {entry_id}.

{exp:channel:entries channel="blog"} 
    {embed="blog/comments" entry_id="{entry_id}"}
{/exp:channel:entries}

In the second template, you call the entry_id using {embed:entry_id} in the comment:entries tag.

{exp:comment:entries entry_id="{embed:entry_id}"}
{/exp:comment:entries}

NOTE: This will be resource intensive if you are printing out lots and lots of data. I wouldn't only use this to do a one off export of entries and comments which seems to be what you're doing. If you get a white screen, you will need to increase PHP memory or limit the number of entries that you are calling.

  • Thanks, the exp:comment:entries is inside of a channel tag. All my posts, etc, export OK, and the comments themselves, but not the url or email. Is that the fatal flaw: the exp:comment:entries inside a channel:entries tag? – markratledge Sep 10 '13 at 1:31
  • Yes, move the tag outside the channel:entries field and it will work correctly. – Anna_MediaGirl Sep 10 '13 at 1:35
  • Your first ideas didn't work, so yes, it must be the nested tags. I added the whole code block above; can you suggest how I move the tags? Thanks. – markratledge Sep 10 '13 at 2:50
  • Just move it outside of the channel:entries tag... So to the bottom of the code... You're passing the entry_id to the comment:entries tag through your embed with {embed:entry_id} which is telling the tag what data to grab... – Anna_MediaGirl Sep 10 '13 at 3:48
  • Ah, thanks, that works, somewhat. But now, no matter what I have for a limit and an offset, I get only one post and its comments (with the email and URL), rather than all of the posts. – markratledge Sep 10 '13 at 4:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.