Static page with dynamic contents managed by WordPress

If you have had my same problem to have a nice enough template to be accepted by your client and your site is mainly a static site but with the necessity of your client to modify and update contents by himself this is the right place.

Short Story
I bought a html template well designed and with all the features I need. My client approved that template and, in the future he would like to edit or correct some part of the contents that are mainly static pages. His tech skills are very low and he already used wordpress for a personal website and he founds a very smart interface and he want it. Definitely.

And now?
I thought about it for some days and I decided to keep my original html template adding some special features that allow some part of contents’ modification.

In which way?

Using a WP CMS to edit contents and printing that contents inside the old html template.

Theoretically easy.

Pratically easy too. You just need to know some bases.

Let’s go doing it.


1. Create a wp installation in a directory of your choice. In my case I installed in root/wp/

2. Rename the index.html in index.php giving the dynamic to the page  (skip this point if you already have a php homepage)

3. copy this code in the very top of your page (in this way you get all the potentiality of wordpress inside your site):


4. now, inside the template put some other code to get the post’s content (or also page if you prefer)

if you want to get the WP contents inside your site, let’s call it e.g. using this method (I get contents from the post n. “1”, change the number to get your specific post):

$post_id = 1
$queried_post = get_post($post_id);
$title = $queried_post->post_title;
echo $title;?>
echo $queried_post->post_content;

If you need the title text you can call it through this method (also in this case the number “1” is related to the post ID number):

<?php echo get_the_title(1); ?>

How to know your post ID?

5. That’s it. Enjoy 😉 Now you can use your wp admin section to modify the text inside your old static html page.