Follow Us :
Create A WordPress Custom Theme

Build a WordPress Custom Theme From Scratch in 13 Easy Steps


WordPress has gained popularity in the recent years but there are many who prefers taking WordPress themes and adding some style as well as using a few WordPress plugins to create a site. It is important that you be at the top of your game so you can build anything that your client asks.
WordPress Local/ Server Development
Local development with:


Desktop Server

Develop site on a live server

WordPress Theme File Structure
To build a WordPress theme, you need to understand the structure of its theme.

Step 1:
Download WordPress and unzip the files where you want to built your site.

Step 2:
Install Your WordPress by Opening your root folder where you have all WordPress files in your browser, Complete Your Installation by filling the required information.

Step 3:
Now navigate to the location wp-content -> themes in your file structure.
Building the WordPress Starter Theme. WordPress has a few pre-installed themes.

Step 4:
In Themes folder you need to create a new folder with the name of Your Theme. Now you can plan on creating a theme.

Step 5 :
Understanding the Structure of a basic site:
Before we go further with this, let us give you a brief introduction to the parts of a web page.

The boilerplate code is divided into 4 groups:



Main Content


In WordPress, These groups are placed in different files(we can also further divide our code in small contents and call them in our files).

Step 6:
Now, Create Some Files in your recently created folder:







Also add a folder name Bootstrap And Add bootstrap files in it (here bootstrap 3 is used)Step 7:
Edit your style.css file. At the top of the file, enter a few comments to let WordPress know the theme name.
Copy And paste the code below in your style.css and replace it with your information.

Theme Name: Your Theme Name
Theme URI:
Author: Author Name
Author URI:
Description: A basic theme from scratch
Version: 1.0
Text Domain: textdomain

Few of the comments:

Theme name: The name of the theme.

Theme URI: URI from where you can download the theme.

Author: Name of the Developer

Description: What is it meant for, what was the idea behind it etc.

Version: If you are planning to upload your theme to WordPress Repository.

License: GNU license for free use.

Tags: These are the tags you can see throughout

Text Domain: The name used by translators of your theme.

Step 8:
Code to add to functions.php
You can add Bootstrap scripts or style to the functions.php.

* Enqueue scripts and styles optional if you want to add bootstrap styling
function theme_enqueue_styles() {
wp_register_style('bootstrap', get_template_directory_uri() . '/bootstrap/css/bootstrap.min.css' );
$dependencies = array('bootstrap');
wp_enqueue_style( 'theme-style', get_stylesheet_uri(), $dependencies );
function theme_enqueue_scripts() {
$dependencies = array('jquery');
wp_enqueue_script('bootstrap', get_template_directory_uri().'/bootstrap/js/bootstrap.min.js', $dependencies, '3.3.6', true );
add_action( 'wp_enqueue_scripts', 'theme_enqueue_styles' );
add_action( 'wp_enqueue_scripts', 'theme_enqueue_scripts' );
Register Menu
function register_my_menu() {
register_nav_menu('header-menu',__( 'Header Menu' ));
add_action( 'init', 'register_my_menu' );
* Add a sidebar.
function wpdocs_theme_slug_widgets_init() {
register_sidebar( array(
'name' => __( 'Main Sidebar', 'textdomain' ),
'id' => 'sidebar-1',
'description' => __( 'Widgets in this area will be shown on all posts and pages.', 'textdomain' ),
'before_widget' => '<li id="%1$s" class="widget %2$s">',
'after_widget' => '</li>',
'before_title' => '<h2 class="widgettitle">',
'after_title' => '</h2>',
) );
add_action( 'widgets_init', 'wpdocs_theme_slug_widgets_init' );
* Add Custom logo support to upload
add_theme_support( 'custom-logo' );

Step 9:
Now, Edit Your header.php
Code to add to the Theme Header file

<!doctype html>
<html <?php language_attributes(); ?>>
<meta charset="<?php bloginfo( 'charset' ); ?>" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<link rel="profile" href="" />
<?php wp_head(); ?>
<body <?php body_class(); ?>>
<div class="site-content">
<div class="container-fluid">
<div class="row">
if( function_exists( 'the_custom_logo' ) && has_custom_logo()) {
the_custom_logo(); //add custom logo by uploading through dashboard in Appearance->customization
<a href="<?php echo get_option('home'); ?>">
<?php bloginfo('name'); ?></a>
<div class="description">
<?php bloginfo('description'); ?>
<?php } ?>
<nav id="navigation" class="navbar navbar-inverse">
<div class="container">
<div class="row">
<div class="blog-nav collapse navbar-collapse" id="nav-list">
'theme_location' => 'header-menu',
'menu_class' => 'header-menu',
'items_wrap' => '<ul id="%1$s" class="%2$s navbar-nav ml-auto">%3$s</ul>',

Step 10:
Code to add to the Theme Footer
Edit footer.php

</div><!-- /.container-->
</div><!-- /.row-->
</div><!-- /.site-content-->
<footer class="footer container-fluid navbar-inverse">
<div class="footer row">
<div class="text-center text-muted">
<p>Basic Blog built by Enterprise Web Cloud</p>
<?php wp_footer(); ?>

Step 11:
Edit Your index.php
Once this is done, the index file should be sparse. The new index.php is ready.

<?php get_header(); ?>
<div class="container">
<div class="row">
<div class="col-sm-8 blog-main">
if ( have_posts() ) {
while ( have_posts() ) : the_post();
<div class="blog-post">
<h2 class="blog-post-title"><?php the_title(); ?></h2>
<p class="blog-post-meta"><?php the_date(); ?> by <?php the_author(); ?></p>
<?php the_content(); ?>
</div><!-- /.blog-post -->
} ?>
</div><!--/.blog-main -->
<?php get_sidebar();

Step 12:
Edit Your sidebar.php

Add few Css For styling add below code to your style.css

.blog-nav li {
position: relative;
display: inline-block;
padding: 10px;
font-weight: 500;
.blog-nav li a {
color: #fff;
.blog-sidebar li {
list-style: none;

Step 13:
To Create New Menu:
Login To Your WordPress Dashboard And Follow Steps as shown in Screenshot Below:

To make your WordPress theme work properly, add a few basic functions.

Title tag option help in removing it from header.php and pull it from WordPress.

Post thumbnails will enable you to have thumbnails on every post on your site

You can build as many navigation menus as you want but you’ll need to register them first.

The Loop
This the most exciting part as it will enable to dynamically insert content, and here we do that with the loop. One of the most important function of WordPress and your content will be generated through a loop.

The Loop is quite simple

<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
<!-- contents of the loop -->
<?php endwhile; endif; ?>

This is self-explanatory: IF there are posts, WHILE there are posts and DISPLAY these posts. Anything that is inside the loop will be repeated.
There is still much more to learn about WordPress theme. Some of the elements that aren’t integrated are navigation, site header, and sidebar which are static HTML.
Now, log in and go to Appearance > Themes and you’ll see your theme. Activate your theme and your work is done. Congratulations!

Download The Complete Theme Package Here

Get Our Latest Tips & Tricks Updated

error: Content is protected !!