WordPress has a perfect wrapper for HTML > Theme conversion: The theme itself. All information can be found in the Codex page.
It is enough to add a folder to your wp-content/themes
directory (or whatever directory you registered in addition to that), and add the following files
functions.php
style.css
index.php
header.php
to your custom themename
folder. Then use the Plugins API to attach some callbacks into the execution flow of WordPress core. This is where you would define basic things like adding stylesheets or scripts. Example for your functions.php
:
add_action( 'wp_enqueue_scripts', function() {
// Register Stylesheets and Scripts in here
// @link https://developer.wordpress.org/reference/functions/wp_enqueue_script/
} );
In your header.php
, you add the opening calls for your HTML:
<!DOCTYPE html>
<html <?php language_attributes(); ?>>
<head>
<?php wp_head(); ?>
</head>
The wp_head();
function calls all the actions and this is where you registered scripts and stylesheets will appear.
In you index.php
, you will add your body markup:
<?php get_header(); ?>
<body <?php body_class(); ?>>
<!-- Markup from your HTML files -->
<?php get_footer(); ?>
</body>
The get_footer();
function will call a footer.php
file if you include one.
Finally you just need to add Page templates that replace the original PHP files. Those do not really differ from the index.php
above, except for one thing: The header comment. Let's assume you add a copy of your index.php
, rename it to about-us.php
and add the following as first line:
<?php /** Template Name: About Us */ ?>
Now, when you in the admin UI go and add a new page, you can select this new template, you will have a replacement file for some existing HTML file. You can even adjust the slug in the admin UI page edit screen.
All that should give you a good start to converting your HTML templates to a valid WordPress theme. You can later and depending on your contract go and make those templates dynamic bit by bit – for example by splitting out repeating sidebars, make menus adjustable, change the title and the content.
<link>
tags in your themesheader.php
file.