Add a Sidebar in Two Steps

Adding a sidebar to WordPress is quite fast and easy, and it usually requires more work to style and position it than to technically add it to the theme. If you need to add a sidebar to a specific page or section of the website you need to know how the template hierarchy works. If you are not sure of which template file WordPress is using for a certain page or your theme has customized the template hierarchy then a plugin like What The File can be of great help.
Continue Reading

Problems with jQuery? Make sure you upload the right library

Today I’ve run into a problem on a client’s site, and I want to share with you how I figured it out.

A couple of weeks ago I wrote a very simple accordion function to make a description appear/disappear inside a download box. Today, my client wrote to me saying that the accordion didn’t work anymore, and the description text was always visible. First thing, I checked with Firebug that the script was correctly added to the head of the page. I always use the plugin Header and Footer to add my scripts to posts and pages, and it always worked but you never know. My first guess was that the script for some reason was added before the jQuery library is loaded. In such case the script would not work because it uses a library that is not yet available. However, that was not the case.

When you find yourself in such situation it’s easy to get frustrated. The secret is to stay calm and analyze the situation. The script was working previously, so it could not be a bug in the script itself. After some research I tried to see if the Firebug console was giving me any error. And here I started to understand. I got an error saying TypeError: $(…).accordion is not a function. So, that was definitely a problem with the jQuery library. It didn’t take long to figure it out. The accordion is a function of jQuery UI which is a separate library from the standard jQuery library. The WordPress theme that my client was using uploaded the jQuery library but not the jQuery UI library, so the accordion didn’t work.

To fix that I simply added the two following lines to all the head sections of pages and posts through my Header and Footer plugin:

<script type="text/javascript" src=""></script>
<script type="text/javascript" src=""></script>

So, why did it work before? I think that for a lucky case some plugin loaded the library. The client disabled a few plugins in the last two days and that broke my script.

Lesson learned, always verify that you have the right libraries loaded before writing any script, don’t assume that they are there. It will save you a lot of frustration and debugging hours!

Introduction to ‘The Loop’

Sooner or later it had to come the moment of talking about the WordPress loop. The Loop is one of the core functions in WordPress, probably the function that makes WordPress so different compared to any other CMS.

The Loop displays posts, pages and custom posts. You simply cannot write code for WordPress if you don’t understand how to use the Loop.

Continue Reading

How to Create Your Template Hierarchy in WordPress

When I decide to learn a specific topic I like to dig deep into it, and understand as much as possible about that topic. Simply learning how the standard template hierarchy works wasn’t enough for me. My problem now was that I wanted to be able to create my personal template hierarchy. After having seen how flexible WordPress is I was sure that it’s possible to do it, and in fact I was right. I’ve found the right hook to understand this topic in a talk given by Kostantin Kovshenin at a WordCamp in Sofia (yes, it was in English, and no, I don’t talk Bulgarian). I watched the video last week, and I was fascinated by the power and simplicity of the mechanism. You can literally turn WordPress upside down. The whole talk includes also an explanation of how to use a filter to alter the WordPress hierarchy but since I haven’t discussed yet filters and actions I’ll let this for another article. Continue Reading

Understanding The Template Hierarchy (part 2)

In the last article about the template hierarchy I probably forgot to cover an important point, so I’m going to amend now and clarify a few things. I analyzed what happens when someone access the home page of a WordPress website, what templates WordPress looks for and loads first. Now I’ll go deeper into the templates that determine how the home page will look like. Continue Reading

Understanding The Template Hierarchy (part 1)

In this series of articles I’ll try to analyse the structure of the template hierarchy and how WrodPress manages it. I will also try to go deeper and look at the WordPress functions that allow you to completely change that hierarchy to your like. As always, this is the analysis of a beginner learner, so I hope you’ll forgive me if I make some mistakes. Continue Reading

10 Ways To Find Information For WordPress Developers

After I decided that I wanted to become an expert WordPress developer I immediately found a problem; where do I find the information that I need? The question is not so trivial as you may think. As a learner, you need to find good quality information to improve your skills, so you have to rely on other people’s willing to share their knowledge. It’s easy to find information about WordPress, there are tons of blogs around. The problem is to find good quality information for beginner developers. Even if today I cannot claim that I’m the most expert in finding information, I can say that I’ve developed a few methods that I’m going to share with you. Continue Reading

Another blog about WordPress?

A few months ago I decided to enter the WordPress design and development arena, and learn the inner working of WordPress so that I’ll be able to develop themes and plugins. I’m not really sure whether I’ll ever write a theme or a plugin, my only aim is to be an advanced coder and being able to make complex websites with WordPress.

As soon as I started being more involved with the community I felt in love with everything related to WordPress. It’s not just a technical thing. A few years ago I was involved in the Linux community, and I’ve been the Italian coordinator of the TLDP, an organization for making and distributing documentation and howtos about Linux. I strongly believe in the open source philosophy, and always applied it in my past jobs leaving always my colleagues astonished. WordPress represents exactly that philosophy, and it demonstrates how openness can create a fantastic ecosystem. So, I wanted to be part of that community, and give my contribution to all of this. But here was the problem. There are hundreds if not thousands of blogs and websites that talk about WordPress, what can I say that is not already said? At this point, I put the project on hold, waiting for some ideas, and in the meantime I started my journey into the WordPress development. And then I realized what is missing. I haven’t been able to find resources that explain how to develop under WordPress to a newbie like me. All the blogs publish articles for people who have already a certain level of knowledge, so they leave out some details that for a newbie can make the difference between understanding and not understanding.

Here is where I come, I will write about my learning process, explain what I don’t understand and how I find the solution, and I will publish my coding experiments. I hope that all of this will be useful to someone, this is my way to give back to this fantastic community. If no one will read this blog, my posts will be useful to me as notes to consult when I won’t remember some detail. Since learning is a long process, I’m not sure I’ll publish every week, but this blog is a work in progress where everything is always under construction. The look of the website is not the final one, and the layout either but it will likely remain about the same. Regarding my posting, learning is a long process, and I’m not sure I’ll be able to publish code and experiments every week, but I will stick to a weekly posting schedule, so I will always post something hopefully useful about WordPress.

Just a final disclaimer: this is not going to become a “learn to code” blog. I will talk about WordPress assuming that my reader already knows PHP, JavaScript, OOP and the like at least at a basic level. If you don’t know anything about coding there are fantastic free courses that can teach you the principles of programming better than I could. For example, one you should check out is  If you need a more specific training in PHP you can find it at