A Fun Simple Explanation of How WordPress Works!
WordPress is far more than a CMS or Blogging system; it is an incredibly flexible development framework. ! Our development practice is working with the WordPress framework, not within WordPress.
Let’s explore the framework with the analogy of building a shelter. Let’s role play a little game where you are ship wrecked on a deserted tropical island named www.yourdomain.com and you need some form of shelter fast. A tent is a pretty simple shelter and with WordPress installed we can include the wp-blog-header.php in our index.php page and now have a simple web page capable of utilizing all the glory of WordPress. Holy Guacamole Revy! Are you saying that is all I need to do to access the WordPress core? Yes, I am saying exactly that.
Living on this island is great! We now call it the Grand and Exalted Kingdom of Candyland and a tent is not befitting of royalty. Let’s add some walls to our palace. Four walls would be pretty boring and we definitely need a door so we can get inside to get our stuff. We can do this by adding in the LOOP.
The LOOP gives us a quick way to access all the contents of our palace. It was a hard day playing in the surf and laying in the sun so we decide to head back to our shelter and grab some coconut juice. The LOOP works by letting us know if we have any coconuts (content), and if we do have coconuts the LOOP gets the coconut for us, opens it and pours it in a glass! Did I forget to mention that our island is an enchanted island?
We are getting really tired of living in our single room palace so now we call up the LOOP to harness the power of the Template Hierarchy. I was reading an ad from a WordPress Designer/Developer the other day, and in this add they claimed they did not use templates in their sites. I was a bit bemused by this because the Template Hierarchy is one of the greatest aspects of WordPress. Let’s use our shelter analogy to see why.
WordPress uses the page templates to define not only the layout but functionality of each page. There are several templates included with WordPress, however, you can create as many different templates as you need… and each one can be laid out completely different. Let’s add a bedroom to our palace. We want a grand bedroom with a retractable roof like the one in the Swiss Family Robinson. ? Without the Template Hierarchy this would be time consuming task. With the Template Hierarchy this is easy. We can build the template file for bedroom.
The bedroom template might start off as a copy of the main room but we can start to change it through the use of logic, mark-up and Template Tags. Template Tags are like magical elf inhabitants of your WordPress island. Each elf has a magical power that you can call on. Remember the coconut juice? The name of the coconut elf was the_content(). There are elves to do most anything you want WordPress Codex, for example we can have wp_login_url() act as a security guard for our bedroom.
Time to add our retractable roof. The cool thing here is that if we want to add a retractable roof to another room we can build it using the PLUG-IN and WIDGET APIs. Of course if you happen to find a really good Retractable Roof plugin laying around the island you could just add a widget area to your palace functions with the register_sidebar() and then use the get_sidebar() template tag in any template to make widget container. Now just drop in the Retractable Roof plugin and voila! You have a retractable roof.
The enchanted island and shelter analogies could go on for pages; in fact, an entire book could be written on the subject of the WordPress frame work. We have only covered a very small portion of the framework. There are APIs for Database, Themes, Plugin, Widget, Rewrite just to name a few. A complete list can be found on the WordPress Codex.
You are not limited to just the WordPress APIs there are several extension APIs. One of the more notable is the WP REST API. The use of REST API allows for the even greater flexibility of using the incredibly powerful WordPress back-end to manage content for use in modern MVC ! front-ends or sharing posts with your other sites.
By building to the power of the WordPress Framework we are able create unique creative sites without the “Just Another WordPress Site” look and feel.