Using WordPresses’ RSS import, I was able to copy every post from blogCFC easily. WordPress expects a local file when doing so. And blogCFC’s rss feed is limited to 15. To override that, edit file ‘blog.cfc’. It will be in the following path under your blogCFC installation: /org/camden/blog/. Just set arguments.params.maxEntries to something very very high. If you have less than 1500 posts, the following will do (starting at around line 742):
<!--- Right now, we force this in. Useful to limit throughput of RSS feed. I may remove this later. --->
<cfif (structKeyExists(arguments.params,"maxEntries") and arguments.params.maxEntries gt 15) or not structKeyExists(arguments.params,"maxEntries")>
<cfset arguments.params.maxEntries = 15>
</cfif>
<cfset arguments.params.maxEntries = 1500>
Then, reinit your session to refresh the blog’s cache. Then go to your feed’s url with your web browser. You should have every single article there. Save that rss as a local xml file. Upload that file into WordPress. Great!
But comments are not copied. So I made and used the below script to copy all post comments from blogCFC to WordPress. Not too difficult! 10 minutes tops.
First, prep the blogCFC database. In the tblblogentries table (where blogcfc keeps the blog posts), add a column named ‘wpid’. For each row, enter WordPresses’s ID of the same post. I had 43 entried so it did not take a heck of a long time. Just sort both tables by title and do it. I suppose you can write a script for this too, but not worth the effort for 43 entries.
With that done, here is the CF code:
<cfquery name="read" dataSource="your-blogcfc-datasource">
SELECT tblblogcomments.*, tblblogentries.wpid
FROM tblblogcomments INNER JOIN tblblogentries ON tblblogcomments.entryidfk = tblblogentries.id
</cfquery>
<cfoutput query="read">
#wpid# #name# #email# #posted# #website#<br>
<cfquery name="ins" dataSource="your-wordpress-datasource">
INSERT INTO wp_comments
(comment_post_ID, comment_author, comment_author_email, comment_author_url, comment_date, comment_content, comment_approved)
VALUES
('#wpid#', '#name#', '#email#', '#website#', '#posted#', '#comment#', 1)
</cfquery>
</cfoutput>
Run that page in a browser and all comments are imported! Nice. Then one more step. For each WP post, you have to update the post count. Again, not a big deal. Sort your WP comments table (wp_comments) by comment_post_id and do some simple math.
ColdFusion, MySQL, News
WordPress
Recent Comments