Plugins Plugin hub Backup SEO Caching Security Forms WooCommerce Images Best backup plugins
Hosting Hosting directory Shared hosting Managed WordPress Cloud hosting VPS hosting By reader location Hosting finder
Themes & builders Compare Rank Math vs Yoast
Tools All tools Hosting finder Plugin stack builder Cost calculator Salt generator Theme detector Who is hosting this? Speed test Headline analyzer robots.txt generator Redirect generator Uptime calculator Blog name generator
Blog Best backup plugins Deals
Guides All guides Speed up WordPress Choose hosting Back up WordPress
How we test

Developer · Guide

How to Convert PHP Website to WordPress (Step by Step)

How to Convert PHP Website to WordPress (Step by Step)

Short answer

Install WordPress on staging, split your PHP templates into a custom theme that uses the Loop, then move content by hand or with an import script. Replace custom features with plugins, add 301 redirects for changed URLs, and test before switching the domain.

Key takeaways

  • There is no one-click converter for custom PHP sites.
  • Your old header, footer and page templates become theme files.
  • Large sites are best imported with a script using wp_insert_post.
  • Custom post types suit products, listings and other structured data.
  • Every changed URL needs a 301 redirect to protect SEO.

How do you convert a PHP website to WordPress?

You convert a PHP website to WordPress by installing WordPress, turning your existing HTML and PHP templates into a custom theme, moving the content into posts and pages, and redirecting old URLs to the new ones.

There is no one-click converter for custom PHP sites. Every hand-built site is structured differently, so the work is a careful rebuild rather than an import.

The good news is that your PHP skills carry over. WordPress itself is written in PHP, and its themes are ordinary PHP files with some special functions.

This guide walks through the full process in the order most developers follow.

StageWhat you doMain tools
1. AuditList pages, URLs, features and dataSpreadsheet, crawler
2. Set upInstall WordPress on stagingLocal or staging host
3. ThemeSplit templates into a WordPress themeCode editor
4. ContentMove pages, posts and dataImporter, WP-CLI, scripts
5. FeaturesReplace custom PHP featuresPlugins or custom code
6. RedirectsMap old URLs to new onesRedirect plugin or server rules
7. LaunchTest, switch DNS, monitorSearch Console, logs

Why convert a custom PHP site to WordPress?

Most owners convert so non-developers can edit content, add pages and install features without touching code, while still keeping PHP-level control when needed.

A custom PHP site often depends on one developer. Small text changes need a code edit and an upload. WordPress gives editors a visual editor, user roles and revision history.

You also gain a large plugin library for things like SEO, forms, caching and backups. That replaces a lot of custom code you would otherwise have to maintain.

If you are moving from a different platform rather than raw PHP, our general guide on migrating a website to WordPress may suit you better.

What should you audit before converting?

Before you write any code, list every URL, page template, dynamic feature and database table on the old site, because anything you miss here usually breaks after launch.

Build a spreadsheet with these columns:

  • Old URL
  • Page type, such as static page, article, product or listing
  • Template file that renders it
  • Dynamic features, such as forms, search, login or filters
  • New WordPress URL

A site crawler can collect the URLs for you. Also export the list of indexed pages and top landing pages from Google Search Console so you know which pages matter most for traffic.

Then look at the database. Note which tables hold content, which hold users, and which hold settings or logs you can leave behind.

How do you set up WordPress for the conversion?

Install WordPress on a staging or local environment first, so you can build and test the new site without touching the live PHP site.

You can use a local tool or a staging site on your host. Keep the old site running until the new one is fully ready.

Check the server requirements on the official WordPress requirements page. Your old site may run on an older PHP version than WordPress recommends.

Then set the basics:

  1. Choose your permalink structure under Settings > Permalinks, ideally matching old URLs where you can.
  2. Set the site title, time zone and reading settings.
  3. Create the user accounts editors will need.

How do you turn PHP templates into a WordPress theme?

Split your existing layout into WordPress theme files, such as a header, footer and page templates, and replace hard-coded content with WordPress template tags and the Loop.

A minimal classic theme needs only two files: style.css with a theme header comment and index.php. Most conversions add a few more:

Old site fileWordPress theme file
header.php or top includeheader.php with wp_head()
footer.php or bottom includefooter.php with wp_footer()
Home page templatefront-page.php
Article templatesingle.php
Generic page templatepage.php
Listing or archive pagearchive.php or home.php
Shared functions filefunctions.php

The Loop replaces your own database queries for main content. A simple page.php looks like this:

<?php get_header(); ?>
<main>
<?php while ( have_posts() ) : the_post(); ?>
  <h1><?php the_title(); ?></h1>
  <?php the_content(); ?>
<?php endwhile; ?>
</main>
<?php get_footer(); ?>

WordPress decides which template to use based on the template hierarchy. Learning it early saves a lot of confusion.

You can also build a block theme instead, using HTML templates and theme.json. That suits teams who want editors to change layouts in the Site Editor.

How do you load CSS and JavaScript the WordPress way?

Load your stylesheets and scripts with wp_enqueue_style() and wp_enqueue_script() in functions.php, instead of hard-coding link and script tags in the header.

Enqueuing lets WordPress and plugins manage load order and avoid loading the same library twice. It also lets caching plugins combine or delay files safely.

function mysite_assets() {
    wp_enqueue_style( 'mysite-main', get_template_directory_uri() . '/css/main.css', array(), '1.0' );
    wp_enqueue_script( 'mysite-app', get_template_directory_uri() . '/js/app.js', array(), '1.0', true );
}
add_action( 'wp_enqueue_scripts', 'mysite_assets' );

The theme handbook explains this in its guide to including CSS and JavaScript.

Remove any old jQuery copy you bundled yourself. WordPress ships its own, and loading two versions causes errors.

How do you move content into WordPress?

Move small sites by hand, and move larger sites with an import script that reads your old database and creates posts with wp_insert_post() or WP-CLI.

For a site with 20 or 30 pages, copying and pasting into the block editor is often fastest. You can clean up the formatting as you go.

For hundreds or thousands of records, script it. A one-off PHP script loaded inside WordPress can read the old table and create posts:

$rows = $olddb->get_results( "SELECT title, body, slug, created FROM articles" );
foreach ( $rows as $row ) {
    wp_insert_post( array(
        'post_title'   => $row->title,
        'post_content' => $row->body,
        'post_name'    => $row->slug,
        'post_date'    => $row->created,
        'post_status'  => 'publish',
        'post_type'    => 'post',
    ) );
}

The wp_insert_post reference lists every field you can set, including categories and custom fields.

If you export the old data to CSV, an import plugin such as WP All Import can map columns to fields without custom code. Our guide on useful WP-CLI commands covers command-line options too.

Remember images. Download them from the old server, upload them to the media library, and update image paths in the content. A search and replace on the database helps with leftover old paths.

What about custom data like products or listings?

Store structured data such as products, team members or listings in a custom post type with custom fields, rather than forcing it into normal posts or pages.

Register the post type in your theme or a small plugin with register_post_type(). Then add fields with a fields plugin or with post meta.

Our guide on creating a custom post type shows the code step by step.

If the data is relational and complex, such as bookings or inventory linked across many tables, you can keep a custom table. Query it with the global $wpdb object, which handles escaping and prepared statements.

How do you replace custom PHP features?

Replace each custom feature with a well-maintained plugin where one exists, and rebuild only the truly unique logic as custom code in a plugin.

Common swaps include:

  • Contact forms: a form plugin with spam protection.
  • Site search: core search or a search plugin.
  • Member login: WordPress users with roles.
  • Sitemaps: built in since WordPress 5.5, or an SEO plugin.
  • Image resizing: handled by the media library.

For unique features, put the code in a small custom plugin instead of functions.php. That way the feature survives a theme change.

If your old site had AJAX calls to a custom PHP endpoint, rebuild them with admin-ajax or the REST API. Our guide on making AJAX requests in WordPress shows both approaches.

How do you keep your SEO when switching?

Keep URLs the same where you can, and set up 301 redirects from every old URL that changes, so visitors and search engines land on the right new page.

Old PHP sites often have URLs like /article.php?id=42. WordPress uses clean permalinks such as /my-article/. Each of those needs a redirect.

You can add redirects with a redirect plugin or with server rules. Google explains why permanent redirects matter in its guide to redirects and Google Search.

Also carry over titles, meta descriptions and headings for your top pages. After launch, watch for 404 errors and fix them quickly. Our guide on fixing broken links after migration covers that clean-up.

How do you launch the new WordPress site?

Launch by testing everything on staging, taking a final content sync, backing up the old site, then pointing the domain to the new WordPress install and monitoring for errors.

Use this launch checklist:

  1. Test every template, form and feature on desktop and mobile.
  2. Check page speed and fix any heavy assets.
  3. Back up the old PHP site and its database.
  4. Copy any content added to the old site since you started.
  5. Move WordPress to the live domain and update the site URL.
  6. Switch DNS or swap the document root.
  7. Test redirects for your top URLs.
  8. Submit the new sitemap in Search Console.

Keep the old site files for a few weeks in case you need to check something.

Turn on debug logging briefly after launch to catch PHP notices from your new theme code, then turn it off.

Frequently asked questions

Is there a tool that converts PHP websites to WordPress automatically?

Not for custom PHP sites. Each one is built differently, so tools cannot reliably guess where content and layout live. Importers help with data in CSV or common formats, but the theme and features need to be rebuilt by a developer.

Can I reuse my existing PHP code in WordPress?

Often, yes. Layout code moves into theme templates, and business logic can move into a custom plugin. Replace your own database queries with WordPress functions or the wpdb object, and load scripts with the enqueue functions rather than hard coded tags.

How long does it take to convert a PHP site to WordPress?

A small brochure site can take a few days. A site with many templates, a large database and custom features like bookings or member areas can take several weeks. The audit stage gives you the most accurate estimate.

Will converting to WordPress hurt my search rankings?

It does not have to. Keep URLs where possible, add 301 redirects for every changed URL, carry over titles and descriptions, and fix 404 errors after launch. Some short-term movement is normal, but rankings usually settle when redirects are correct.

Should I build a classic theme or a block theme?

A classic theme is closer to how custom PHP sites work, so it is often faster for developers. A block theme lets editors change layouts in the Site Editor. Choose based on who will maintain the design after launch.

Sources

  1. Template hierarchy WordPress Developer Resources
  2. Including assets WordPress Developer Resources
  3. wp_insert_post() WordPress Developer Resources
  4. Server requirements WordPress.org
  5. Redirects and Google Search Google Search Central
  6. PHP manual PHP.net

Is your product missing, or something out of date?

Tell us what to add or correct. We read every note and reply when we need a source. A message does not buy a ranking.

About the editors

Written and checked byWPLegible Editorial Team Independent WordPress reviews and guides

Researched from the primary sources listed above and checked against our editorial rules before publishing.