As WordPress developers, we often need a way to store and retrieve data. The most common reason for that is that we need to store and retrieve settings for our plugin or theme. But the reality is that there are countless of other reasons why you’d need to store and retrieve data.
So how do we do it? Well, the primary tool that we have at our disposal to do this is the options API. It’s an API that offers a way for us to store and retrieve data from the WordPress database.
It’s pretty much as indispensable as the plugin API. We often can’t build anything in WordPress without it. That’s why it’s worth looking a bit deeper at how it works.
Continue reading WordPress for the adventurous: Options API
It’s not too far-fetched to see WordPress as a library. You write a post and publish it. Meanwhile, WordPress classifies it and puts it away on its shelves.
But how do you find your post again after WordPress shelved it away? You need someone to help you navigate this huge library and find what you’re looking for. You need a librarian!
That’s the job of the
WP_Query class in a nutshell. It’s the librarian of the WordPress database. You talk to it when you want to search through the WordPress database. It’ll help you find the information that you need!
It does this without requiring that you know how WordPress stores that information. That means that you don’t have to know how to write MySQL queries.
WP_Query takes care of all that for you. (Yay!) It’ll transform your search request into a safe MySQL query and process it for you.
But how does the
WP_Query class do this? That’s what we’re going to look at today. We’re going to explore how it works and what it can do for you. This will help you leverage it to the maximum in the future.
Continue reading WordPress for the adventurous: WP_Query class
Let’s say that you ran a poll through the WordPress developer community. It asked the following question: “What defines WordPress?”. The odds are that the plugin API would come up near the top.
From a developer’s perspective (and for the sake of my introduction), there’s nothing that defines WordPress like it. It’s the workhorse of the WordPress ecosystem. You use to build anything that you want with WordPress.
There are plenty of articles out there that show you how to use it, but little on how it works. That makes it a bit misunderstood and lonely (APIs have feelings you know).
It’s time we showed some love for this hard worker.
Continue reading WordPress for the adventurous: Plugin API
The story behind rewrite API plays out almost like a Disney movie. You have WordPress and the human (played by you!). Two different worlds. Two different languages.
WordPress is a machine and only understands if you talk to it as such. You need to use a cold language of numbers and code so that it can understand you. Do you need to see a WordPress post? You need to ask him using query variables like
On the other hand, humans are friendly and talkative. They expect to talk to someone using words. They want to see URLs with the
post-title and not query variables.
The rewrite API is the translator that brought these two unlikely friends together. Rewrite rules convert your
post-title into the
p=123 query variable WordPress wants. Both sides get their happy ending (yay!).
Continue reading WordPress for the adventurous: Rewrite API
I’m sure you woke up thinking “I wish I knew more about WordPress loading.”. Ok… maybe not (it’s just me isn’t it?). It’s just not something you deal with every day.
No, plugins and themes make up your days. That’s what you use to build your custom WordPress solutions. There’s no need to know about the internal process that starts up WordPress.
Yet you can’t ignore it once you start building complex WordPress solutions. Or if you plan on distributing a plugin or theme. That changes the dynamic of things.
Your little world with the plugins and themes you know is gone. You’re in the larger (and messier) WordPress world now. That means you have to play nice with everyone else (damn).
Continue reading WordPress for the adventurous: Loading
To master WordPress, you have to be able to look at it from unusual perspectives. It’s exploring these perspectives that gives you that next level understanding. You’re able to view problems from another angle. This can give you unique insights that affect how you approach problems and design solutions for WordPress.
The angle we’re going to explore in this article is the concept of the entry point. Let’s take a look at how WordPress handles it.
Continue reading WordPress for the adventurous: Entry points