Migrate from WordPress to PagibleAI CMS

The WordPress importer moves the posts of a WordPress site into PagibleAI as blog articles below a blog page, together with their media, SEO data, former URLs and access restrictions. WordPress pages and other post types aren't imported. Rebuild them in PagibleAI, or let an AI agent copy them using the MCP tools.

WordPress 4.0 or newer is supported, including the classic editor and the block editor. Older versions aren't tested. They also don't store the site language in the database, so pass it with --lang.

This guide covers the WordPress-specific parts. Read Migrate to PagibleAI first for installing the importer, the options all importers share and the checklist after the import.

Connect the WordPress database

Add the WordPress database to the connections array in config/database.php:

'wordpress' => [
    'driver' => 'mysql',
    'host' => env('WP_DB_HOST', '127.0.0.1'),
    'database' => env('WP_DB_DATABASE', 'wordpress'),
    'username' => env('WP_DB_USERNAME', 'root'),
    'password' => env('WP_DB_PASSWORD', ''),
],

Don't add a prefix setting to the connection. Pass the table prefix of the WordPress site ($table_prefix in its wp-config.php) with --prefix instead. The default is wp_. For one blog of a multisite installation, use its prefix, e.g. --prefix=wp_2_.

Run the import

Check what would be imported first:

php artisan cms:wp-import --domain=example.com --dry-run

Then run the import. This example puts the articles below a blog page at /news and assigns the pagible theme to the articles and the blog page:

php artisan cms:wp-import --domain=example.com --theme=pagible --blog-path=news --blog-name=News

The pages are imported in the language of the WordPress site unless you pass --lang. If the WordPress site discourages search engines from indexing it, as staging sites often do, the imported pages aren't indexable either. Add --index to import them as indexable pages.

Translations of multilingual plugins like WPML or Polylang aren't imported as language variants. Each translated post becomes a separate article in the --lang language. Delete the translated articles after the import and translate the originals in PagibleAI instead, as described in Multilingual websites.

What is imported

  • Posts: Published, scheduled and private posts. Scheduled posts become pending versions, which cms:publish publishes at their date.
  • Featured images: The featured image is shown in the article element at the top of the page and used as image for social media. Posts without featured image use the first image of their content as preview in blog lists.
  • Content: Gutenberg blocks and classic content, including images, galleries, files, embeds, tables, code, buttons and reusable blocks. The shortcodes [caption], [gallery], [embed], [audio], [video], [playlist] and [code] are converted too.
  • Links and redirects: Links to other posts point to their new pages. Former slugs and permalinks become redirects.
  • Media: Files below wp-content/uploads are downloaded into the PagibleAI file storage. Other media keeps its external URL.
  • SEO: Yoast SEO and Rank Math data become the meta data of the pages. The categories and tags of the posts are added to the keywords, together with the focus keyphrases of the SEO plugins.
  • Skipped and reported: Dynamic blocks like latest posts and query loops, other shortcodes, forms and scripts. Rebuild them with PagibleAI elements or dynamic content.
  • Not imported: WordPress pages, custom post types, category and tag archives, comments, users and accounts. Links to the archives keep their old URLs.

Media in other locations

If the uploads were moved with wp-config.php constants like UPLOADS or by a plugin, e.g. to a CDN, pass their base URL with --media-url. Media below these URLs is downloaded as well. The option is repeatable, and the first value also replaces relative wp-content/uploads paths:

php artisan cms:wp-import --domain=example.com --media-url=https://cdn.example.com/uploads

Private posts

Private posts are restricted to the WordPress roles that can read them. This requires frontend access control in PagibleAI and access values with the same names as the WordPress roles. If a role has another name in PagibleAI, map it with --role:

php artisan cms:wp-import --domain=example.com --role=editor:staff --role=administrator:staff

Roles without a matching access value are skipped. If frontend access isn't set up or none of the roles exists, private posts become disabled pages instead.

Options

Besides the common options like --domain, --lang, --editor and --since, the WordPress importer accepts:

Option
Default
Description
--prefix
wp_
Table prefix of the WordPress site, e.g. wp_2_ for one blog of a multisite
--blog-path
blog
URL path of the parent blog page
--blog-name
Blog
Name of the parent blog page
--type
blog
Page type of the articles
--theme
Theme of the articles and the blog page
--media-url
Base URL of the uploads; repeatable, the first replaces wp-content/uploads paths
--role
WordPress role mapped to another access value, e.g. editor:staff; repeatable
--index
Make the pages indexable even if WordPress discourages search engines

Run the import again

Run the same command again to update the articles while editors still work in WordPress. Use --since with the date of the last run to import only the posts changed since then. If posts aren't imported any more, e.g. because they were deleted or unpublished, their pages are disabled. Articles changed in PagibleAI since the last import aren't overwritten. See Migrate to PagibleAI for the details.

Troubleshooting

The import fails with a missing table error

The table prefix is wrong. Pass the $table_prefix value from the wp-config.php of the WordPress site with --prefix, e.g. --prefix=wp_2_ for the second blog of a multisite, and check that the connection has no prefix setting.

Private posts were imported as disabled pages

Frontend access isn't set up, or none of the WordPress roles that can read the posts exists as access value in PagibleAI. Set up frontend access control, create the values or map the roles with --role, and import again.

Images still load from the WordPress site

Only media below wp-content/uploads or a --media-url base is downloaded. Pass the base URL of the moved uploads with --media-url and import again.

The imported articles aren't indexed by search engines

The WordPress site discourages search engines from indexing it (Settings → Reading). Import again with --index.

A shortcode or block is missing

Plugin shortcodes, forms, scripts and dynamic blocks can't be converted and are listed as warnings in the output. Rebuild them with PagibleAI elements.

Translated posts appear as separate articles

WPML and Polylang store translations as separate posts, so they are imported as separate articles. Delete the translated articles and translate the originals in PagibleAI, see Multilingual websites.