How I joined multiple Bootstrap themes with my official WordPress site

I thought I should write down this without delay and share with my readers. These are bits and pieces of my experiences of writing my official website It was a kind of trial and error method that I had always expected that, well – touch wood, it’d survive somehow.
And it survived the experiments. Google started indexing it and I think the time has also come to play with Google analytic.
Let me finish it very fast and start from the very beginning.
I decided to inject multiple bootstrap CSS styling in my website. It’s a kind of bootstrapping wordpress.
As you know, when you start building a wordpress site from scratch you need few files at the very beginning. They are – style.css and few more PHP files like index, page, home, header, footer, sidebar etc.
I decided to make the front page a static page so I injected a ‘front-page.php’ file in that beginning procedure.
As of now I am keeping three styles – two of them are open source bootstrap theme and the other one is the mystery (please download it from my github repository).
The first step is – make your default style intact so that it does not break.
My ‘style.css’ code:
@import url('css/font-awesome.min.css');
@import url('css/bootstrap.min.css');
@import url('css/animate.css');
@import url('css/style.css');

body {


Next get the link in the ‘header.php’ file:


I don’t want the ‘Home’ navigation in my first page menu bar so just excluded it with a simple code:
wp_list_pages(array('title_li' => '', 'exclude' => 4));
Remember wordpress keeps everything as ‘post’ inside database. My home page post id is 4 and I’m excluding it from the first page navigation.
You know the other wordpress pages more or less follow this same logic:

if ( have_posts() ) : while ( have_posts() ) : the_post();
I decide to get the permalink, time, title, and content after that so the functions are easy:
the_time('l, F jS, Y'); //you can change the format, please search in the codex

You should also keep an error message if something goes wrong with your code.
_e('Sorry, there are no posts.');
As I said before: there are three themes as of now. So I need two more template files. One is for Blog and the other, the custom one is for any other purposes.
You need ‘header-blog’, ‘footer-blog’, ‘header-custom’, and ‘footer-custom’. And in the related template file don’t forget to write like this:

Besides these simple routine I decided to show one category in my custom styling. I’ll write this part in detail.
Finally my website looks like this:

The Home page:

The blog Page:

The Contact page:

The archive page:

And finally I decided to show my ‘PHP’ category posts in the custom styling:

So this is it. For full code please visit my Github repository:


Null coalescing operator in PHP 7

Let us consider a code of checking the age first. It checks whether the ‘age’ is given in the form or not. If it’s not given, then it says ‘not mentioned’. When it’s given it just spits out the age. Very basic thing we normally did when php 7 had not come.

$age = isset($_GET['age']) ? $_GET['age'] : 'not mentioned';


As usual it’ll give an output of – ‘not mentioned.’ Now we write this code with the age given.

Continue reading “Null coalescing operator in PHP 7”

Adapter Pattern in PHP

Can we Adapt SMS into MAIL?
Now we’re going to do an impossible task.
Are you prepared?
Can we start?
This chapter is about the adapter pattern. It’s one of the design patterns that you’re currently on. Let us start with a real world example.
You know that internet connection is absolutely necessary for sending emails. Is it true in the real world? You’d say, well, I know that. An internet networking is a must.

Continue reading “Adapter Pattern in PHP”

Chain of responsibility in php

Let us see how Responsibility can be Unchained!
In object-oriented design, the chain-of-responsibility pattern belongs to behavioral design patterns segment. The simplest example contains a person using ATM. He’s entering pin, receiving payment and receipts etcetera.
What is behavioral design pattern? They are a type of design patterns that generally identify communicating objects.
You may ask, what kind of objects we’re talking about? These objects have common communication patterns between them. While communicating they must realize that patterns.

Continue reading “Chain of responsibility in php”

Decorator Patterns in PHP

When we want to add additional features to our existing classes we generally use decorator pattern.
Do you find this definition useful?
I believe the answer will be NO.
It says about only adding new features. It doesn’t say about how you will use that. Will you add the features by simply hard coding or you’ll add them in the run time.
That’s a pretty big difference.
Let us consider a simple example where we are talking about a hosting company. A typical hosting company sells hosting services and sometimes they also provide template designing.
Let’s design a pretty basic scenario.

Continue reading “Decorator Patterns in PHP”

Object Oriented Programming and PHP 7

Chapter 1. OOP and PHP 7

For absolute beginners, the term OOP or Object Oriented Programming may seem difficult. Some people want to mystify this term very heavily! Why? Because, the uninitiated PHP developers would never try to make their hands dirty and feet wet with code and will depend on them forever.
So the first step is start believing in your potentials, powers and strength of your mind. Coding is like writing. I show you how easy it is!
Consider a piece of writing where you’re trying to describe a robot. So in your writing ‘robot’ is the subject. In object oriented programming the ‘robot’ is the object. In your piece of writing, your subject ‘robot’ has some descriptions like – the robot has three eyes, two noses, six arms.
In OOP we need to write a class ‘Robot’ which has those properties like this:

arm = $arms;
        $this->eye = $eyes;
        $this->nose = $noses;
        echo "The robot has {$eyes} eyes, {$noses} noses, {$arms} arms";
//class ended
$robot = new Robot();
$robot->showRobot(3, 2, 6);

Continue reading “Object Oriented Programming and PHP 7”

How to upgrade to PHP 7

I presume you’re running php 5.x on an Ubuntu 14.04 machine. If you’re windows based, you can easily install Ubuntu 14.04 as a second operating system.
Remember, a genuine php programmer should know a little bit of Linux programming. It’s extremely easy and user friendly. Install Ubuntu on your system and open the terminal by pressing ‘control+alt+t’. For further association with Linux there are tons of free resources available over the internet.
You’ve opened up your terminal; now type this command on it.

sudo add-apt-repository ppa:ondrej/php

A Personal Package Archive, or PPA, is an Apt repository hosted on Launchpad. PPAs allow third-party developers so that they can build and distribute packages for Ubuntu outside of the official channels. They’re often useful sources of beta software – php 7 is also on the developmental stage and it’s not ready for the production environment.

Continue reading “How to upgrade to PHP 7”

Write Your Own Game in Python3

Good VS Bad Game
So far we have learned many things. I hope you have written the codes and tested them and it executed perfectly. Now the time has come to write a simple game in Python. It is a game called “Good Vs Bad”. The game is simple. But as a beginner you may find this code a bit longer. Write them down. Try to add more features.
If you are in Linux environment, save this file as ‘’ and change the file executable by running this command:
Sudo chmod +x
And then run it on your terminal like this:
If you are in Windows, run the IDLE and save the file as ‘’. Press F5 and play the game.

Continue reading “Write Your Own Game in Python3”

Python and Object Oriented Methodology

If you are a complete beginner, you probably for the first time hear about “Object Oriented Programming and Class.” Let us give a brief introduction to Object Oriented Programming (OOP).

10.1 – Object Oriented Methodology
It is based on real world programming. An object is a representation of a real world entity. If there is an object, there must be a class or blueprint behind it. In that class the behaviour of that object is designed or described in detail. These details consist of all the properties and actions that the object performs. There could be many types of objects coming from different classes and they might have relationships. It could be very complicated but you can always break those objects from one another and make some changes. The advantage of Object Orientation is that when you work on a part of a big, complicated project the other part remains unaffected. Our goal is simple. We want to join different objects to create big, complicated software. At the same time we want to make the relations of those objects as loose as possible.
A car object is built of many other objects like tyre, wheel, engine, accelerator etcetera. If you get a flat tyre does the engine stop? It is interrelated and depends on one another. But finally you can work on them individually without affecting other. That is Object Orientation.
Consider an object ‘GoodHuman’. This object must be different from another object ‘BadHuman’. Both come from ‘Human’ class. Now these two objects might have interrelationships and data interactions. Can you imagine how many kinds of properties and methods are there in ‘Human’ class? It could be very complex. Imagine a situation where a ‘BadHuman’ does something ugly. At the same time a ‘GoodHuman’ does some good thing. Whoever does whatever thing the life goes on and that is also Object Orientation.

The Foundation of Object Orientation
Object Orientation is a type of methodology used for building software applications. An Object Oriented program consists of classes, objects and methods. The Object Oriented methodology in software development revolves around a single concept called the object. You can develop software by breaking the application into component objects. These objects interact with each other when the whole application is put together. An object is a combination of messages and data. The object receives and sends messages and those messages contain data or information.
You (an object) interact with your Television (another object) via messages sent through a remote controller (another object).
Consider another real world example of a football. A football has a boundary. It has a specific defined property like bouncing. You can direct or apply few specific actions by kicking it or throwing it.
An object has a state. It may display behaviour. It has a unique ID.
The difference between an object and class is subtle but important. Whereas a class is an abstract concept, an object is a concrete entity. From a class objects with specific properties can be created or instantiated. That is why an object is often called an instance of a class.
One of the major feature of Object Oriented Programming is ‘Polymorphism’. Polymorphism is the capability of something to assume different forms. In Object Oriented Programming polymorphism is the property that a message can mean different things depending on the objects receiving it. The message ‘Accelerate’ means one thing if it sent to an object “OldCar”. But it means different thing to if it is sent to the object “NewCar”. It is a natural concept that can be applied to objects. It also means that similar objects often accept the same message but do different things.
Consider a web page. It is an object. There are billions of such objects around us. When you send a request to an object like web page you actually apply a verb “GET” to a noun “WebPage”. Now every “WebPage” object does not behave the same way when the “GET” verb is applied. Someone open up a PDF file, someone simply shows some texts and pictures and someone may harm your computer. When you double-click a file. It may execute if it is an executable file. Or it may opens up in a text editor if it is a text file. The message is same. That is “Double Click”. But the behaviour displayed by the file object depends on the object itself.
This is Polymorphism. You will learn it heart as you progress through this chapter.
The advantage of Python classes is that it provides all the standard features of Object Oriented Programming. It has the class inheritance mechanism. That allows multiple base classes, a derived class can override any methods of its base class or classes, and a method can call the method of a base class with the same name. Objects can contain arbitrary amounts and kinds of data.
Finally remember, in Python everything is an object. It means there is an abstraction or encapsulation behind it. Your first job is understand that avstraction and the final job is create your own abstraction.