When migrating a blog from Weebly to WordPress, a big challenge is importing comments, because Weebly does not offer a structured export feature for them.
In this post, you’ll learn how to create a full working WordPress plugin that lets you:
- Paste raw Weebly blog HTML into an admin page.
- Preview parsed comments (with author names, dates, and nesting).
- Import comments properly threaded into any WordPress post.
We will provide you the complete code for this plugin — ready to use and customizable!
Why Is This Plugin Necessary?
Weebly stores blog comments directly in the page’s HTML structure without any API or export tool.
Thus, without a custom solution, migrating comments would require manual copy-pasting and you’d lose nested reply structures.
Building this plugin automates:
- Comment parsing
- Duplicate skipping
- Parent-child relationships between comments
And keeps your SEO and user engagement intact after migration.
Full Features of the Plugin
✅ Paste Weebly HTML and preview comments before import
✅ Supports both top-level comments and nested replies
✅ Preserves authors’ names, comment content, and original timestamps
✅ Automatically skips duplicate comments during import
✅ Easy integration via WordPress Tools menu
Step-by-Step: How the Plugin Works
- Admin Interface: A simple admin page under “Tools” where you paste the Weebly blog HTML source.
- HTML Parsing: The plugin uses
DOMDocument
andDOMXPath
to extract:- Author names (linked
<a>
or plain<span>
) - Comment dates
- Comment text
- Comment nesting level (based on CSS classes like
blogCommentLevel0
,blogCommentLevel1
, etc.)
- Author names (linked
- Preview Stage: You can preview all parsed comments before importing.
- Import Stage: On confirmation, the plugin imports all comments into the specified WordPress post, preserving threading.
Full Plugin Code
If you want the full working code, here it is:
👉 Click here to view/download the full Comments Importer plugin code
Below is the complete code of the plugin:
How to Install and Use the Plugin
- Copy the full PHP code into a new file named, for example:
comments-importer.php
- Create a folder called
comments-importer
inside your/wp-content/plugins/
directory and place the file there. - Go to WordPress Admin → Plugins → Activate “Comments Importer”.
- Navigate to Tools → Weebly Comments Importer.
- Paste the HTML source of your Weebly blog post’s comment section.
- Enter the WordPress Post ID where you want the comments imported.
- Preview and then click Import Comments.
That’s it! 🎯
Important Technical Notes
- The plugin safely skips invalid HTML errors using
libxml_use_internal_errors(true)
. - All imported comments are automatically approved.
- Dates are parsed and converted into WordPress-friendly
Y-m-d H:i:s
format. - The plugin uses
wp_insert_comment()
ensuring native WordPress compatibility. - Duplicate checking is done using hashing (
md5
) based on author, date, and content.
Bonus Tips After Importing
- Recount your comment totals if needed with tools like WP-CLI or SEO plugins.
- Check for any missing gravatars or author links.
- Backup your WordPress database before and after the import for extra safety.
🚀 Final Thoughts
Migrating blog comments might sound tedious, but with this simple yet powerful plugin, you can move your community conversations easily from Weebly to WordPress — preserving all user interactions, SEO value, and site credibility.
If you found this tutorial helpful, feel free to share it with anyone planning a Weebly to WordPress migration!