WordPress Website Architecture – Become a Ninja in 15 minutes
WordPress is the most widely used blogging platform and I have been using it for the last couple of years. Though it is an awesome CMS but then like any other CMS is prone to errors and bugs. I have faced several issues with wordpress over the years and have documented solutions to the issues which pop up time and again so that I don’t need to search each and every forum on the web or consult a developer every time I encounter an issue. By the time you will end up reading this post, you should have a better great understanding of the technical side of wordpress which will help you a lot.
Understand WordPress Site Architecture
Half of the wordpress optimization battle is won if we know what we are doing in the first place and understand its consequences. Therefore it is imperative to understand how a wordpress site works and is structured. Without this knowledge you will have a hard time troubleshooting any wordpress issue.

Every wordpress installation comes with a default theme. You can either use this theme or you can use a custom theme. In either case , the theme consist of template files, style sheet files, javascript files, image files and some other files like functions.php. All these files work together to create the design and functionality of your wordpress website. All the wordpress themes’ files live in the folder: /wp-content/themes/. For e.g. all the files associate with the theme named ‘mystique’ resides in the folder: /wp-content/themes/mystique/
Template files are PHP files (.php) which are used to generate web pages and which makes customization possible in wordpress. The more template files your theme has, the more customization you can do. Some template files are used on all the web pages (like header and footer template file), while others are used only under specific conditions. WordPress decides which template files to load when, according to the template hierarchy rules.
Note: The actual name of a template file can vary depending upon the theme you are using.
Understand the functionality of the most common template files used in wordpress
Following are some commonly used template files which you must be aware of:
SNO.
Template File
Description
1
header.php
- This file display headers and navigation.
- If you want to make changes to the head section(<head>…</head> of each web page (like adding the Google Analytics Tracking Code or other tracking code etc) then you need to edit this file.
- You can edit the file by going to your WordPress Admin Panel > Appearance > Editor > header.php
2
Index.php
- This template file is used to display the blog post index.
- The blog post index contains a loop (bunch of PHP code) which displays the most recent blog posts according to some predefined conditions. It displays a list of posts in excerpt or full-length form.
- The blog post index can be set to display on the front page of your website or on a separate static page.
- You can edit this file via your wordpress admin panel > Appearance > Editor > index.php or Settings > Reading.
3
home.php
- This template file is used to display the blog post index.
- The blog post index can be set to display on the front page of your website or on a separate static page.
- If this file is missing then wordpress looks for a file called index.php in the active theme’s directory & uses that template to display the blog post index.
4
Front-page.php
- This template file displays your website’s front Page (which is usually called the home page). The front page can be a static page or a blog posts index.
- WordPress searches for this file first when you load the front page of your wordpress website. If this file is missing then wordpress looks for a file called home.php. If home.php is also missing then wordpress looks for a file called index.php and uses that template to display the front page of your website.
5
page.php
- This template file displays page title and its contents.
- If you are a logged in user with ‘edit’ permission than this file displays the ‘Edit’ link through which you can edit the contents of a page. It also display comment list and comment form.
6
single.php
- The template file displays:
- blog post’s title
- blog post’s content
- author name
- date of the post
- post category & tags
- comment list
- comment form
- Navigation links to the previous and next posts.
- If you are a logged in user with ‘edit’ permission than this file displays the ‘Edit’ link through which you can edit the contents of your blog post.
7
category.php
This template file controls how categories should be displayed.
8
author.php
This template file controls how an author page should be displayed.
9
search.php
This template file controls how a search result page should be displayed and is used when a visitor performs a search on your website. It can display list of posts in excerpt or full length form. Edit this file if you want to customize your search result page.
10
404.php
This template file is used when wordpress cannot find the post or page which is queried. Edit this file if you want to customize your 404 page.
11
footer.php
Edit this file to change the footer of each web page on your site. Many times we need to add tracking code or some javascript just before the </body> tag or edit footer links. Use this file for such purpose.
12
comments.php
This template file decides how the comments should be displayed. It also displays trackbacks, pingbacks & gravatars.
13
style.css
This is the main style sheet file of your wordpress theme and is used to control the design and layout of your web pages. You can also edit this file to change the theme name, author name or author URL.
14
Sidebar.php
This template file is used to control the sidebar display. You can set up the contents of the sidebar widgets through the WordPress admin panel.
15
Functions.php
- This file is used to add your own custom features to your theme. It works like a plug-in file.
- Since this file is theme specific, you lose the custom functionality once you change your theme.
- Not all wordpress themes use this file.
- If this file doesn’t come with your theme, then you can create it under the wp-content/themes/ folder and add PHP functions to it.
Understand the important wordpress Site Files
These are the files which are unique to a particular wordpress installation and contain all your website data:
SNO
WordPress File/Folder
Description
1
/wp-content/
This folder contains all your plug-ins and themes. It also contains all your blog posts and comments (in the ‘cache’ sub-folder). So if you want to take a back up of your wordpress site then first take a back up of this folder.
2
/wp-config.php
This file stores your database information like database name, database username, database password etc. It is a very important file, so don’t mess with it until you know what you are doing.
3
/.htaccess
Another important file for server access control. You can find this file in the root folder via your FTP.
4
/favicon.ico
This is your website favicon file. You can find this file in the root folder via your FTP.
5
/robots.txt
Do we need an explanation here?
Now let us move to the advanced stuff, the practical side of things. How this knowledge can be used to troubleshoot wordpress issues. Here I present to you the most common wordpress issues which I have encountered over the years and how I dealt with them:
Issue #1- How to fix ‘error establishing a database connection’ in wordpress?
This error occurs when you change your database password but do not update your wp-config.php file or vice versa.
Solution: If you change your database password then you also need to update your wp-config.php file (which is located in the root directory /html in FTP file manager). If you don’t update your wp-config.php file then you will get the error message ‘error establishing a database connection’. Open your ‘wp-config.php’ file via FTP and locate the section that looks like this example:
/* The name of the database for WordPress */
define(‘DB_NAME’, ‘putyourdbnamehere’);
/* MySQL database username /
define(‘DB_USER’, ‘usernamehere’);
/* MySQL database password /
define(‘DB_PASSWORD’, ‘yourpasswordhere’); <=Update your password
/* MySQL hostname */
define(‘DB_HOST’, ‘localhost’);
Issue #2 : How to fix the error: “It looks like this is a web page, not a feed”
I have got this error several times so far. This error usually occurs when permalinks stop working properly.
Solution: To make the permalinks work again: Go to your wordpress admin panel > Settings > Permalinks > click on ‘save changes’ button.
Issue #3: RSS feed is showing only one item
Solution- Make sure that the feed URL (like http://www.seotakeaways.com/feed/) is correct. If the feed URL is correct but still your feed is showing only one item, then make sure that your feed is a valid feed via feedvalidator.com
Issue #4: WordPress plugin doesn’t work and you can’t remove it through admin panel
Solution- You need to remove the wordpress plug-in via your FTP. Follow the steps below:
1. Access the FTP of your website
2. Locate the folder ‘wp-content’
3. Look for the folder ‘plugins’ and then open it.
4. Select the plugin folder you want to delete and then right click on it.
5. Choose ‘delete’ from the drop down menu.
Issue #5: You can’t fix the issue with your current wordpress theme & can’t remove it via your admin panel
Solution- You need to remove the wordpress theme via your FTP. Follow the steps below:
1. Access the FTP of your website
2. Locate the folder ‘wp-content’
3. Look for the folder ‘themes’ and then open it.
4. Select the theme folder you want to delete and then right click on it.
5. Choose ‘delete’ from the drop down menu.
Issue #6: Optimizing the speed of your wordpress site
Solution: There are lots of things you can do to optimize the speed of your wordpress site. But it can be really time consuming. So if you are short of time and you just want a switch which can dramatically improve the speed of your website then install the W3 Total Cache Plugin. It is one of the highest rated and most useful wordpress plug-in ever developed. It can dramatically improve your website speed.
Issue #7: Optimizing pages of your wordpress website for SEO
Solution: I have used several plug-ins for this purpose but the one which stands out all the time is the SEO Ultimate Plugin. This all-in-one SEO plug-in gives you control over title tags, meta tags, canonical, 404 errors, rich snippets and tons of other wordpress features.
Issue #8: Removing malware from your wordpress website
Solution: This is one of the most common and serious issue we wordpress users face. Here is what I do to keep my website malware free:
1. Use code gaurd. This tool keeps track of all the changes made to your website. If it notice that the change in code (like changes to the .htaccess file) can harm the normal functioning of the website, then it sends you an alert. It takes hourly, daily and monthly back up of your website.
2. Always keep your wordpress version, plugins and them up to date. Upgrade to the latest version. Every new version comes with a security patch and make your website more secure.
3. Take weekly back up of your website.
4. Be cautious while installing a plug-in or a theme. Sometimes plug-ins/themes contain a malicious code which can harm your website.
5. Scan all your documents/softwares for malware before you make them available for download.
6. Only link out to reputed websites as some websites host malware.
7. Use only reputable advertisers as they are generally malware free.
8. Monitor user generated areas of your website like comments section. Un-moderated comments can have links to malicious websites/files.
Related Post: Malware Removal Checklist for WordPress – DIY Security Guide
Update
I am not a big fan of plug-ins because they tend to slow down a website. But there are some plug-ins which are so useful that i can’t think of running a site without them. Following is the list of must have plug-ins:
1. Akismet - It protects your blog from comment and trackback spam. Without this plugin you will be bombarded with spam sooner or later.
2. PS Disable Auto Formatting – It disables wordpress auto formatting by disabling the function ‘auto formatting (wpautop)’ and save <p> and <br /> formatted content. You need this plug-in to get a control on your blog post formating.
3. W3 Total Cache Plugin - It dramatically improves your website speed and is highly recommended.
4. WP-touch – It automatically transforms your blog into an iphone application style theme. A must have plug-in if you want your visitors to read your blog through smart phones.
5. SEO Ultimate- You need this plugin to easily optimize your wordpress site pages for SEO. Another must have plug-in.
If you like this post then you should subscribe to my blog and follow me on twitter.
Other Posts you may find interesting:
- Excel for SEO – Powerful Cheat Sheet to Boost Productivity
- How to use Web Analytics 2.0 to improve your conversions
- Ultimate Data Visualization Guide for SEO
- How to write a SEO Contract?
- How to Automate Event Tracking in Google Analytics
- Social interactions tracking through Google Analytics
- Google Analytics Account Setup Checklist
- SEO Contract | Sample SEO Contract Template
- Event Tracking – Google Analytics (Simplified Version)
Tweet
WordPress is the most widely used blogging platform and I have been using it for the last couple of years. Though it is an awesome CMS but then like any other CMS is prone to errors and bugs. I have faced several issues with wordpress over the years and have documented solutions to the issues which pop up time and again so that I don’t need to search each and every forum on the web or consult a developer every time I encounter an issue. By the time you will end up reading this post, you should have a better great understanding of the technical side of wordpress which will help you a lot.
Understand WordPress Site Architecture
Half of the wordpress optimization battle is won if we know what we are doing in the first place and understand its consequences. Therefore it is imperative to understand how a wordpress site works and is structured. Without this knowledge you will have a hard time troubleshooting any wordpress issue.

Every wordpress installation comes with a default theme. You can either use this theme or you can use a custom theme. In either case , the theme consist of template files, style sheet files, javascript files, image files and some other files like functions.php. All these files work together to create the design and functionality of your wordpress website. All the wordpress themes’ files live in the folder: /wp-content/themes/. For e.g. all the files associate with the theme named ‘mystique’ resides in the folder: /wp-content/themes/mystique/
Template files are PHP files (.php) which are used to generate web pages and which makes customization possible in wordpress. The more template files your theme has, the more customization you can do. Some template files are used on all the web pages (like header and footer template file), while others are used only under specific conditions. WordPress decides which template files to load when, according to the template hierarchy rules.
Note: The actual name of a template file can vary depending upon the theme you are using.
Understand the functionality of the most common template files used in wordpress
Following are some commonly used template files which you must be aware of:
|
SNO. |
Template File |
Description |
|
1 |
header.php |
|
|
2 |
Index.php |
|
|
3 |
home.php |
|
|
4 |
Front-page.php |
|
|
5 |
page.php |
|
|
6 |
single.php |
|
|
7 |
category.php |
This template file controls how categories should be displayed. |
|
8 |
author.php |
This template file controls how an author page should be displayed. |
|
9 |
search.php |
This template file controls how a search result page should be displayed and is used when a visitor performs a search on your website. It can display list of posts in excerpt or full length form. Edit this file if you want to customize your search result page. |
|
10 |
404.php |
This template file is used when wordpress cannot find the post or page which is queried. Edit this file if you want to customize your 404 page.
|
|
11 |
footer.php |
Edit this file to change the footer of each web page on your site. Many times we need to add tracking code or some javascript just before the </body> tag or edit footer links. Use this file for such purpose.
|
|
12 |
comments.php |
This template file decides how the comments should be displayed. It also displays trackbacks, pingbacks & gravatars.
|
|
13 |
style.css |
This is the main style sheet file of your wordpress theme and is used to control the design and layout of your web pages. You can also edit this file to change the theme name, author name or author URL. |
|
14 |
Sidebar.php |
This template file is used to control the sidebar display. You can set up the contents of the sidebar widgets through the WordPress admin panel. |
|
15 |
Functions.php |
|
Understand the important wordpress Site Files
These are the files which are unique to a particular wordpress installation and contain all your website data:
|
SNO |
WordPress File/Folder |
Description |
|
1 |
/wp-content/ |
This folder contains all your plug-ins and themes. It also contains all your blog posts and comments (in the ‘cache’ sub-folder). So if you want to take a back up of your wordpress site then first take a back up of this folder.
|
|
2 |
/wp-config.php
|
This file stores your database information like database name, database username, database password etc. It is a very important file, so don’t mess with it until you know what you are doing. |
|
3 |
/.htaccess
|
Another important file for server access control. You can find this file in the root folder via your FTP. |
|
4 |
/favicon.ico
|
This is your website favicon file. You can find this file in the root folder via your FTP. |
|
5 |
/robots.txt
|
Do we need an explanation here? |
Now let us move to the advanced stuff, the practical side of things. How this knowledge can be used to troubleshoot wordpress issues. Here I present to you the most common wordpress issues which I have encountered over the years and how I dealt with them:
Issue #1- How to fix ‘error establishing a database connection’ in wordpress?
This error occurs when you change your database password but do not update your wp-config.php file or vice versa.
Solution: If you change your database password then you also need to update your wp-config.php file (which is located in the root directory /html in FTP file manager). If you don’t update your wp-config.php file then you will get the error message ‘error establishing a database connection’. Open your ‘wp-config.php’ file via FTP and locate the section that looks like this example:
/* The name of the database for WordPress */
define(‘DB_NAME’, ‘putyourdbnamehere’);
/* MySQL database username /
define(‘DB_USER’, ‘usernamehere’);
/* MySQL database password /
define(‘DB_PASSWORD’, ‘yourpasswordhere’); <=Update your password
/* MySQL hostname */
define(‘DB_HOST’, ‘localhost’);
Issue #2 : How to fix the error: “It looks like this is a web page, not a feed”
I have got this error several times so far. This error usually occurs when permalinks stop working properly.
Solution: To make the permalinks work again: Go to your wordpress admin panel > Settings > Permalinks > click on ‘save changes’ button.
Issue #3: RSS feed is showing only one item
Solution- Make sure that the feed URL (like http://www.seotakeaways.com/feed/) is correct. If the feed URL is correct but still your feed is showing only one item, then make sure that your feed is a valid feed via feedvalidator.com
Issue #4: WordPress plugin doesn’t work and you can’t remove it through admin panel
Solution- You need to remove the wordpress plug-in via your FTP. Follow the steps below:
1. Access the FTP of your website
2. Locate the folder ‘wp-content’
3. Look for the folder ‘plugins’ and then open it.
4. Select the plugin folder you want to delete and then right click on it.
5. Choose ‘delete’ from the drop down menu.
Issue #5: You can’t fix the issue with your current wordpress theme & can’t remove it via your admin panel
Solution- You need to remove the wordpress theme via your FTP. Follow the steps below:
1. Access the FTP of your website
2. Locate the folder ‘wp-content’
3. Look for the folder ‘themes’ and then open it.
4. Select the theme folder you want to delete and then right click on it.
5. Choose ‘delete’ from the drop down menu.
Issue #6: Optimizing the speed of your wordpress site
Solution: There are lots of things you can do to optimize the speed of your wordpress site. But it can be really time consuming. So if you are short of time and you just want a switch which can dramatically improve the speed of your website then install the W3 Total Cache Plugin. It is one of the highest rated and most useful wordpress plug-in ever developed. It can dramatically improve your website speed.
Issue #7: Optimizing pages of your wordpress website for SEO
Solution: I have used several plug-ins for this purpose but the one which stands out all the time is the SEO Ultimate Plugin. This all-in-one SEO plug-in gives you control over title tags, meta tags, canonical, 404 errors, rich snippets and tons of other wordpress features.
Issue #8: Removing malware from your wordpress website
Solution: This is one of the most common and serious issue we wordpress users face. Here is what I do to keep my website malware free:
1. Use code gaurd. This tool keeps track of all the changes made to your website. If it notice that the change in code (like changes to the .htaccess file) can harm the normal functioning of the website, then it sends you an alert. It takes hourly, daily and monthly back up of your website.
2. Always keep your wordpress version, plugins and them up to date. Upgrade to the latest version. Every new version comes with a security patch and make your website more secure.
3. Take weekly back up of your website.
4. Be cautious while installing a plug-in or a theme. Sometimes plug-ins/themes contain a malicious code which can harm your website.
5. Scan all your documents/softwares for malware before you make them available for download.
6. Only link out to reputed websites as some websites host malware.
7. Use only reputable advertisers as they are generally malware free.
8. Monitor user generated areas of your website like comments section. Un-moderated comments can have links to malicious websites/files.
Related Post: Malware Removal Checklist for WordPress – DIY Security Guide
Update
I am not a big fan of plug-ins because they tend to slow down a website. But there are some plug-ins which are so useful that i can’t think of running a site without them. Following is the list of must have plug-ins:
1. Akismet - It protects your blog from comment and trackback spam. Without this plugin you will be bombarded with spam sooner or later.
2. PS Disable Auto Formatting – It disables wordpress auto formatting by disabling the function ‘auto formatting (wpautop)’ and save <p> and <br /> formatted content. You need this plug-in to get a control on your blog post formating.
3. W3 Total Cache Plugin - It dramatically improves your website speed and is highly recommended.
4. WP-touch – It automatically transforms your blog into an iphone application style theme. A must have plug-in if you want your visitors to read your blog through smart phones.
5. SEO Ultimate- You need this plugin to easily optimize your wordpress site pages for SEO. Another must have plug-in.
If you like this post then you should subscribe to my blog and follow me on twitter.
Other Posts you may find interesting:
- Excel for SEO – Powerful Cheat Sheet to Boost Productivity
- How to use Web Analytics 2.0 to improve your conversions
- Ultimate Data Visualization Guide for SEO
- How to write a SEO Contract?
- How to Automate Event Tracking in Google Analytics
- Social interactions tracking through Google Analytics
- Google Analytics Account Setup Checklist
- SEO Contract | Sample SEO Contract Template
- Event Tracking – Google Analytics (Simplified Version)
About the Author: Himanshu Sharma is the founder of seotakeaways.com which provides SEO Consulting, PPC Management and Analytics Consulting services to medium and large size businesses. He holds a bachelors degree in ‘Internet Science’, is a member of 'Digital Analytics Association', a Google Analytics Certified Individual and a Certified Web Analyst. He is also the founder of EventEducation.com and EventPlanningForum.net.
My business thrives on referrals, so I really appreciate recommendations to people who would benefit from my help. Please feel free to endorse/forward my LinkedIn Profile to your clients, colleagues, friends and others you feel would benefit from SEO, PPC or Web Analytics.
-
Jonny Ross
-
http://www.car-hire.net/ Joana
-
odlasb
-
David
-
Mridul Sharma
-
automatic updates don’t work
-
http://www.scotlandart.com/ Robin jones
-
http://keith-fraley.com Keith
-
http://www.nicoclub.com Greg
-
http://www.ascentinternet.com Ascent Internet
-
http://yoast.com/ Joost de Valk – Yoast
-
http://blogbar.es Miguel
-
http://abelpardo.info Abel Pardo






...