Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Extending WordPress migration classes
The builtin wordpress_migrate classes can be extended for custom situations, such as mapping incoming postmeta data to node fields. The basic approach:
1. Extend the appropriate class, such as the WordPressBlogEntry class with your custom behavior - add field mappings in __construct(), manipulate the body ($row->content) in prepareRow(), etc.
2. Extend the WordPressBlog class, and override migrationClasses to point to your custom classes:
class MyCustomBlog extends WordPressBlog {
public function migrationClasses() {
$classes = parent::migrationClasses();
$classes['WordPressBlogEntry'] = 'MyCustomBlogEntry';
$classes['WordPressPage'] = 'MyCustomPage';
return $classes;
}
}
3. Set the wordpress_migrate_blog_class variable to point at your WordPressBlog class. For example, add this to settings.php:
$conf['wordpress_migrate_blog_class'] = 'MyCustomBlog';
Comments
Perform import change using devel module
How do you configure WordPress Migrate to spawn a drush command to perform the import from within the devel module??
rgds Dave
@Dave: The devel module has a
@Dave: The devel module has a variable editor at http://www.example.com/devel/variable, where I was imagining you could add the variables described above. However, it looks like it only supports editing and deleting variables, not adding them, so it won't help you. I'll remove that reference from the docs.
Note that there are no notifications of comments on documentation, it's pure happenstance that I saw this just a few days after you posted it (and it'll be happenstance if you see this reply) - the issue queue is a much better place to post questions about a module than on the documentation pages.
Where is the best place to
Where is the best place to put these classes?
any update?
have you figured out where the classes are placed?
I placed it in a custom
I placed it in a custom module and it worked.
Can you describe with a few
Can you describe with a few more details? I can't make it work by following those instructions. The default class is still used.
This was a while, but I just
This was a while, but I just checked and I put it in the actual .module file.
I just noticed that I have an include file in the module info that's really not there, so I must have tried that first and then probably needed to put it on the .module file to work, although I am back guessing here.
Hope this helps.