You’ve decided to move a WordPress site that already has traffic onto Payload, and you want every post to land in typed fields without losing a URL. If you’re still weighing the two, our Payload vs WordPress comparison covers that decision first.
As of 26 November 2026, Payload’s latest stable release is 3.94.2, published on 24 November, and WordPress is on 7.1.5. Payload has no WordPress importer. Its Import Export plugin reads CSV and JSON files, so moving a WordPress site is a script you write on Payload’s Local API. Our checklist for migrating to Payload covers the same move from any other CMS.
This guide moves an interior design studio in Dubai through every step, with code checked against Payload 3.94.2. The studio has about 180 posts written in the block editor, 40 project pages built with Advanced Custom Fields (ACF), Yoast SEO, two authors and about 2,500 images.
- What moves from WordPress to Payload, and what you rebuild?
- Step 1: take stock of the WordPress site
- Step 2: get the data out of WordPress
- Step 3: model the content as collections, globals and blocks
- Step 4: convert post HTML and Gutenberg blocks to Lexical
- Step 5: import media first, then point images at it
- Step 6: import everything with a script on the Local API
- Can WordPress users keep their passwords in Payload?
- Step 7: keep your URLs, SEO fields and redirects
- Step 8: run a test import, then cut over
- How we’d move a WordPress site onto our Payload template
- Frequently asked questions
- What to do next
What moves from WordPress to Payload, and what you rebuild?
Your content moves, and a script carries it. The theme, templates and plugin behaviour are rebuilt in your front end and Payload’s config.
| In WordPress | In Payload | How it moves |
|---|---|---|
| Posts and custom post types | A collection per type | Script |
| Pages | A pages collection with a blocks field for the layout | Script, layouts mapped to blocks |
| ACF repeater, group and flexible content | Array, group and blocks fields | Script |
| Categories, tags, custom taxonomies | Collections, linked by relationship fields | Script, before the posts |
| Menus | A global | Script or by hand |
| Media library | An upload collection, stored through a storage adapter | Script, first |
| Users and authors | An auth collection | Script, with new passwords |
| Yoast or Rank Math titles and descriptions | The SEO plugin’s meta fields | Script |
| Permalinks | Slugs, plus entries in the Redirects plugin | Script, applied by your front end |
| Comments | A collection you add, or a comments service | Script, if you keep them |
The studio’s ACF gallery and flexible-content field, for instance, become an array of uploads and a blocks field, as our guide to Payload fields explains.
Payload’s official cms-migration skill can draft these collections with you in an AI coding agent. It leaves extraction, images inside posts, passwords and redirects to you.
Step 1: take stock of the WordPress site
Before writing code, count every post type per status, ACF field group, block type, shortcode, plugin that stores content and sitemap URL, so you can check the import against them.
The block editor stores each block in post_content as an HTML comment, such as <!-- wp:gallery -->, and shortcodes as text in square brackets, such as [contact-form-7 id="12"]. Search post_content for both to see which need their own handling in step 4.
For example, the studio’s inventory reads 182 published posts and 6 drafts, 40 projects, 2,514 media files and 2 authors. Its posts use standard blocks, galleries and one custom “before and after” block, plus a contact form shortcode on four posts.
Step 2: get the data out of WordPress
You can use the REST API, the XML export, WP-CLI or the database, and each gives you something the others don’t.
| Route | What you get | What it leaves out | Use it when |
|---|---|---|---|
REST API (/wp-json/wp/v2/) | JSON, rendered HTML, raw block markup with context=edit, Yoast’s fields | Anything not exposed to REST; 100 records per request | The site is live and you can sign in |
| XML export (Tools, Export) | One WXR file with posts, pages, custom post types, comments, custom fields, terms, menus and authors | Image files (only URLs); custom fields come raw, some serialised PHP; plugin tables | One snapshot without the API |
WP-CLI wp export | The same WXR, filtered and split by size | As the XML export; needs shell access | Large sites, repeated exports |
| The database | Every table, plugin tables included | Nothing is rendered, and meta can be serialised PHP | Plugin data no export carries |
The REST API returns at most 100 records per request, with the page count in the X-WP-TotalPages header (WordPress pagination docs). Public requests get content.rendered, the HTML after WordPress has run blocks and shortcodes. With context=edit and an Application Password, which WordPress has shipped since 5.6, you also get content.raw with the block comments intact. It carries that user’s full permissions, so create one for the move and revoke it after.
This script saves each type to a JSON file, 100 records at a time:
// fetchWordPress.ts: run once, then work from the files
import { writeFile } from 'node:fs/promises'
const site = 'https://studio.example.com'
const auth = Buffer.from(`${process.env.WP_USER}:${process.env.WP_APP_PASSWORD}`).toString('base64')
async function fetchAll(type: string) {
const items: unknown[] = []
let page = 1
let totalPages = 1
do {
const status = ['posts', 'projects'].includes(type) ? '&status=any' : ''
const res = await fetch(`${site}/wp-json/wp/v2/${type}?per_page=100&page=${page}&context=edit${status}`, {
headers: { Authorization: `Basic ${auth}` },
})
if (!res.ok) throw new Error(`${type} page ${page}: ${res.status}`)
totalPages = Number(res.headers.get('X-WP-TotalPages'))
items.push(...(await res.json()))
page++
} while (page <= totalPages)
await writeFile(`${type}.json`, JSON.stringify(items, null, 2))
}
for (const type of ['media', 'users', 'categories', 'tags', 'posts', 'projects']) {
await fetchAll(type)
}A custom post type appears in the REST API only when it’s registered with show_in_rest, and ACF fields only when their field group has Show in REST API switched on. The studio’s projects type needs both.
Step 3: model the content as collections, globals and blocks
Write the Payload collections before importing anything, each with a field that keeps the WordPress ID, so the import can find what it already created and map old IDs to new ones. New to Payload? Our Payload tutorial starts a project from its templates.
For example, the studio’s projects become this collection:
// collections/Projects.ts
import type { Block, CollectionConfig } from 'payload'
const BeforeAfter: Block = {
slug: 'beforeAfter',
fields: [
{ name: 'before', type: 'upload', relationTo: 'media', required: true },
{ name: 'after', type: 'upload', relationTo: 'media', required: true },
],
}
export const Projects: CollectionConfig = {
slug: 'projects',
admin: { useAsTitle: 'title' },
versions: { drafts: true },
fields: [
{ name: 'title', type: 'text', required: true },
{ name: 'slug', type: 'text', required: true, unique: true, index: true },
{ name: 'wpId', type: 'number', unique: true, index: true, admin: { readOnly: true } },
{
name: 'gallery',
type: 'array',
fields: [{ name: 'image', type: 'upload', relationTo: 'media', required: true }],
},
{ name: 'body', type: 'richText' },
{ name: 'layout', type: 'blocks', blocks: [BeforeAfter] },
],
}Add the SEO plugin with collections: ['posts', 'projects'] and it puts a meta group with a title, a description and, once you set uploadsCollection, an image on both collections (SEO plugin docs). The studio’s main menu becomes a global with an array of links. On Postgres, run Payload’s schema migrations first so the tables exist; they’re separate from this content migration.
WPML and Polylang store each language as its own post, while Payload keeps every language on one document, so set up locales first with our guide to Payload localisation.
Step 4: convert post HTML and Gutenberg blocks to Lexical
Payload stores rich text as Lexical JSON, and convertHTMLToLexical from @payloadcms/richtext-lexical turns WordPress HTML into it. You pass your editor config and the JSDOM class from jsdom, which you install yourself (Payload’s converting HTML docs).
// toLexical.ts
import { convertHTMLToLexical, editorConfigFactory } from '@payloadcms/richtext-lexical'
import { JSDOM } from 'jsdom'
import type { Payload } from 'payload'
export async function makeConverter(payload: Payload, mediaIds: Map<number, number | string>) {
const editorConfig = await editorConfigFactory.default({ config: payload.config })
return (html: string) => {
const dom = new JSDOM(html)
for (const img of dom.window.document.querySelectorAll('img')) {
const wpId = Number(img.className.match(/wp-image-(\d+)/)?.[1])
const mediaId = mediaIds.get(wpId)
if (mediaId) {
img.setAttribute('data-lexical-upload-relation-to', 'media')
img.setAttribute('data-lexical-upload-id', String(mediaId))
}
}
const state = convertHTMLToLexical({ editorConfig, html: dom.window.document.body.innerHTML, JSDOM })
// upload IDs arrive as text; numeric IDs, Postgres's default, must be numbers
const fixIds = (node: any) => {
if (node.type === 'upload' && /^\d+$/.test(node.value)) node.value = Number(node.value)
node.children?.forEach(fixIds)
}
fixIds(state.root)
return state
}
}The converter makes the Lexical nodes your editor config enables and never a Payload block, because Payload’s block node has no HTML import in @payloadcms/richtext-lexical 3.94.2. A gallery, an embed or a custom block comes through as whatever its inner HTML converts to.
The rendered HTML is what visitors saw, with shortcodes already run. The raw markup keeps each block’s name and settings in its comment, such as <!-- wp:gallery {"ids":[211,212]} -->, so your script can save it as a Payload block instead. The comments themselves don’t become text, and an unrendered shortcode stays as text in square brackets.
In the studio’s case, posts convert from content.rendered as they are, except the custom “before and after” block. The script reads that block’s two image IDs from the raw markup and saves a beforeAfter block instead.
Step 5: import media first, then point images at it
Import every file before any post, and keep a map from each WordPress attachment ID to the new media ID. The Local API’s create takes a filePath on disk or a file in memory and writes it through your upload collection’s storage adapter. Each post’s featured_media is an attachment ID, so featured images resolve through the map.
WordPress gives each inserted image a wp-image-{ID} class with its attachment ID, and the converter in step 4 uses it. An <img> that carries data-lexical-upload-relation-to and data-lexical-upload-id becomes an upload node pointing at that media document. The converter keeps that ID as text, while Payload’s upload validation needs a number when IDs are numbers, as they are on Postgres by default, so step 4’s converter turns them back into numbers. Any other <img> becomes a pending upload with no collection, which the same validation returns as an invalid selection, so map every image or remove it before converting.
For example, a studio post shows kitchen-600x400.jpg, a scaled copy of the original attachment. Matching on the class links the post to the original you’ve already imported. Where the class is missing, strip the -600x400 suffix and look the original up by file name.
Step 6: import everything with a script on the Local API
The import script writes through the Local API in an order where nothing points at a document that doesn’t exist. For the studio, that’s media, authors, categories and tags, services, then projects and posts.
// import.ts
import config from '@payload-config'
import { readFile } from 'node:fs/promises'
import { getPayload } from 'payload'
import { makeConverter } from './toLexical'
const payload = await getPayload({ config })
const read = async (type: string) => JSON.parse(await readFile(`${type}.json`, 'utf8'))
// create or update by WordPress ID, so a second run updates instead of duplicating
async function upsert(collection: 'media' | 'categories' | 'posts' | 'projects', wpId: number, data: any, file?: any) {
const found = await payload.find({ collection, where: { wpId: { equals: wpId } }, limit: 1, depth: 0 })
const options = { collection, data: { ...data, wpId }, context: { importing: true } }
return found.docs[0]
? payload.update({ ...options, id: found.docs[0].id })
: payload.create({ ...options, file })
}
const mediaIds = new Map<number, number | string>()
for (const item of await read('media')) {
const res = await fetch(item.source_url)
if (!res.ok) { console.warn('media', item.id, res.status); continue }
const data = Buffer.from(await res.arrayBuffer())
const name = item.source_url.split('/').pop()
const doc = await upsert('media', item.id, { alt: item.alt_text }, { data, mimetype: item.mime_type, name, size: data.length })
mediaIds.set(item.id, doc.id)
}
// authors, categories, tags and services follow the same pattern, each filling a map
const categoryIds = new Map<number, number | string>()
const toLexical = await makeConverter(payload, mediaIds)
for (const post of await read('posts')) {
await upsert('posts', post.id, {
title: post.title.raw,
slug: post.slug || post.generated_slug,
publishedAt: post.date_gmt && `${post.date_gmt}Z`,
heroImage: mediaIds.get(post.featured_media),
categories: post.categories.map((id: number) => categoryIds.get(id)).filter(Boolean),
content: toLexical(post.content.rendered),
_status: post.status === 'publish' ? 'published' : 'draft',
})
}Each write carries context, which every hook on the request can read, so hooks can skip revalidation during a bulk load. Local API calls skip access control by default, as our guide to Payload’s APIs explains.
The _status field, which Payload adds when drafts are switched on, keeps WordPress drafts as drafts. The filter on categories drops any term the import didn’t map, such as one added after the export, so one gap doesn’t fail the post. As written, one failed write stops the run, so wrap each upsert in try and log the WordPress ID; then a test run lists every failure.
Can WordPress users keep their passwords in Payload?
Not as they’re stored. WordPress keeps older passwords as phpass hashes starting $P$ and, since WordPress 6.8, new ones as bcrypt hashes starting $wp$2y$ (WordPress core announcement). Payload’s built-in sign-in checks its own PBKDF2-SHA256 format (payload 3.94.2).
That leaves two routes:
- Reset. Import each user with a long random password, since Payload requires one to create a user, then send a reset email with the Local API’s
forgotPassword. If the collection verifies email addresses, create each user with_verified: trueanddisableVerificationEmail: true, because a reset doesn’t verify an account. - Check the WordPress hash once. Keep each user’s WordPress hash in a hidden field and add a
beforeOperationhook for login. On a first sign-in it checks the password against that hash, saves it as a Payload password and clears the old hash, before Payload’s own check runs. You write the phpass and bcrypt checks yourself.
Start with the reset route, as the studio does for its two authors. Our guide to Payload authentication covers how sign-in and password resets work.
Step 7: keep your URLs, SEO fields and redirects
Keep each slug, copy the SEO fields into Payload, and redirect every URL whose path changes, so every indexed address still answers.
With Yoast active, the REST API adds yoast_head_json to each post (Yoast REST API docs), so the export from step 2 holds each post’s title and description, HTML entities still encoded. Decode them, drop the site name Yoast adds to each title if your front end adds its own, and write them into the SEO plugin’s meta group. The Redirects plugin adds a redirects collection, where each entry has a from path and a to that’s either a reference to a document or a custom URL.
// postId: the Payload ID the import gave this post
await payload.create({
collection: 'redirects',
data: {
from: '/majlis-refit',
to: { type: 'reference', reference: { relationTo: 'posts', value: postId } },
},
})Next.js drops a trailing slash by default, so store each from without one, and list posts in the plugin’s collections so the reference can point there. Like the import, create a redirect only when its from isn’t there yet.
The plugin only stores redirects, so your front end has to read them and send the redirect, in middleware or in Next.js’s redirects config. Payload’s website template at v3.94.2 does this in a component on its page and post routes, which looks up the path in the redirects collection and calls Next.js’s redirect(). Next.js serves redirect() as a 307, a temporary redirect, and permanentRedirect() as a 308. A dated permalink such as /2019/05/post-name/ reaches neither route, so it needs middleware. For a moved page, send a permanent one. Pages you drop on purpose should return 410.
For example, the studio’s posts move from /%postname%/ to /blog/{slug}, so each of its 182 published posts gets a redirect. Its projects keep /projects/{slug}/ and need none.
Step 8: run a test import, then cut over
Run the whole import into a copy of the Payload database first. Count each collection against step 1, open a sample in the admin, and crawl every old URL on the new site for its status, title and redirect. When a count is off, fix the mapping and run the script again.
For example, the studio’s test run shows 186 posts against 188. The two missing are drafts, whose slug WordPress leaves empty unless someone sets one, while the collection requires one, which is why step 6’s script falls back to the generated_slug that context=edit returns.
When the counts match, agree a content freeze with the editors, run the import against production, and point the domain at the new site. Our guide to deploying Payload covers going live, and the migrations checklist covers the Search Console weeks after.
How we’d move a WordPress site onto our Payload template
As of our template’s v2.13.1 (17 November 2026, on Payload 3.93.0), a new project starts from our defaults, and we change them case by case as the project requires. It ships with pages, media and users, and a WordPress post type maps onto pages, media, users or a custom collection we add for that project, whichever fits. Pages build their layout from a blocks field, where ACF flexible content or page-builder sections go, and rich text can hold images. The SEO plugin’s fields sit on pages and on any project collection that needs them, so Yoast’s title, description and image have a home. Media goes through a storage adapter, with Vercel Blob as our default, or the adapter a project’s hosting calls for.
Every WordPress site has its own structure, so we write a one-off script for each site on Payload’s Local API, mapping what’s in WordPress onto Payload’s collections and features. The Redirects plugin is on, and by default a project’s redirects are handled in its routing, with how they’re managed set per project. Sign-in is Payload’s own email and password by default, and we extend it case by case, for example with Better Auth or by accepting WordPress sign-ins, as a project needs.
We’ve moved a WordPress marketplace onto Payload before. The content went across as a database export and a script. The importer refused to write an image reference it couldn’t resolve and logged it, which turned up images already missing on the live site, and a crawler compared every old URL on both hosts, as our Payload vs WordPress guide describes in full.
A Payload migration with us starts by reviewing the content, data, URLs and integrations and modelling the new system before anything moves, then plans field mapping, cleanup, redirects, validation and launch.
