Karma HTML Web Template: Using PHP Includes

[box type=”note”]Important: Your web server must support PHP in order to use the information outlined below.[/box] [box type=”download” icon=”empty”]Please note: This articled is provided as a guide but this modification is outside the scope of TrueThemes customer support. We are unable to provide further support for this modification however if you need expert coding assistance we highly recommend http://www.wpqustions.com [/box]


This article outlines how to convert certain areas of your Karma HTML Website Template into PHP Includes. PHP Includes are beneficial because they enable you to make site-wide updates by editing only a single file. If you’ve never worked with PHP Includes we highly recommend checking out this article before proceeding: http://www.htmlandphp.com/beginner-php/introduction-to-php-includes.html

Here’s a quick overview of the modifications required:

  1. Decide which areas of your website are suitable for a PHP Include
  2. Create the PHP Include(s)
  3. Rename each file in your website from ‘.html’ file to ‘.php’
  4. Add the PHP Includes(s) throughout your website

Step 1: Decide which areas of your website are suitable for a PHP Include:

Suitable areas for a PHP Include are areas which have “the same content” throughout every page in your website. This can include things like Footer Copyright information, Footer Navigation, etc. In this tutorial we will outline how to turn the Footer Copyright and Footer Navigation into a PHP Include.

Step 2: Create the PHP Includes:

  1. Open up an existing HTML file within your website (ie. template-leftnav.html)
  2. Scroll to the bottom of this file and copy the HTML code responsible for Footer copyright and navigation. (see screenshot #1 below)
  3. Create a new file in your code editor and paste in the HTML code you just copied. This file should contain only the HTML code copied and no other code.
  4. Save this new file as a PHP file. In this example we will save this file as: include-footer.php

Screenshot #1. (click for full-size view)

Step 3: Rename each file in your website from .html to .php:

PHP Includes can only be called from within a PHP file. This step requires you to change each HTML file within your website from ‘.html’ to ‘.php’. In this example we will rename template-leftnav.html to template-leftnav.php. This process will need to be repeated for each HTML file within your website.

Step 4: Add the PHP Includes(s) throughout your website:

We now need to add our newly created PHP Include to template-leftnav.php

  1. Open up template-leftnav.php in your code editor.
  2. Scroll to the bottom and locate the “Footer Bottom” HTML code which we copied in step 2.
  3. Remove the HTML code and include our PHP:
<?php include 'include-footer.php'; ?>


Our static HTML code has now been replaced by a PHP Include. We will repeat this process throughout our entire website. The quickest way to do this is to use our code editor’s “find and replace” function. We will “find” the Footer-Bottom HTML code and replace it with our PHP Include above. Updating the Footer information in our website will now a much smoother process. Anytime we want to update our Footer information we will only need to modify the single include-footer.php file.

Karma WordPress:

We highly recommend checking out our Karma WordPress Theme. WordPress is an incredibly powerful platform that uses PHP and Databases to pull in our content, and it will do all of the below steps along with a vast amount of other awesome functions making it super-easy to maintain our website. Karma WordPress Theme →