Advertising sustains the DA. Ads are hidden for members. Join today

Advanced WordPress Migrate

Last updated on
30 April 2025

You are browsing documentation for an older version of Drupal, which is not supported any longer, and the information may not be correct. See current documentation for Contributed modules

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';

Help improve this page

Page status: Not set

You can: