If you're someone who is just getting started working with WordPress, then it's natural to be curious about some of the advanced features offered by its API. So where might you stand regarding your experience?
Whatever the case, you're ready to continue to building things with WordPress, but you're not yet sure where to go next.
More specifically, maybe you're not quite ready to begin using the of these advanced features in your work, but as you start to solve more and more problems using the CMS, then it makes sense for you to wonder:
How might I achieve [this particular task] using WordPress?
After all, that's the natural progression of this type of work.
In this series, we're going to look at how to do that using the native WordPress APIs. By the end of it, you should be familiar with some of the advanced options relating to metadata and how to think creatively regarding using it in your work.
But first, who is this series targeting? That's a fair question.
If you're an experienced developer, then you're likely familiar with what we're going to cover in this series, so it may not be as applicable to you. If, however, you're someone who's a beginner-to-intermediate developer, then this should help to increase your skills.
Ultimately, it's written for anyone who is not familiar with the various WordPress metadata APIs. So regardless of your level of experience, you should come out of the end of this series with a clear understanding of each one and how to incorporate it into your work.
With that said, let's get started.
Often, you'll hear metadata defined as "information about information". That's not a bad definition. Even Wikipedia defines it as such:
Metadata is "data that provides information about other data". Two types of metadata exist: structural metadata and descriptive metadata. Structural metadata is data about the containers of data. Descriptive metadata uses individual instances of application data or the data content.
But what does this look like within the context of WordPress? Before answering that question, it's important to understand that (at the time of this writing) WordPress offers four types of metadata:
Each of these has a unique relationship with the larger entity to which it's related. By that, I mean that post metadata is clearly related to WordPress posts (and pages and custom post types).
Similarly, comment metadata is all about extra information that's associated with comments that are left by visitors.
And the newest form of metadata to WordPress is term metadata. For those who aren't familiar with taxonomies or terms, this is something that will have a bit of a learning curve. No worries, though. We're going to be taking a look at each of these in detail.
Posts are arguably the most recognized entity in WordPress. After all, this is where we draft, schedule, and manage the content that goes out on our blog.
Nearly everything else can be tied back to posts. For example:
But, for now, what constitutes post metadata?
If you were to look at the WordPress post meta table (often represented as wp_postmeta in your database), for example, you'd see which template is associated with a given post. You'd see the files related to a particular post. You may even find other information that gives you insight as to how a developer associated some custom information with the post.
At first glance, it can be insightful. What's even more powerful is how you can leverage this to increase the amount of information related to a post. And as we work through this series, we're going to see exactly how to do that.
At this point, you're likely getting an idea as to how metadata works within the context of WordPress. As previously mentioned, it's not just limited to posts. Using the WordPress API, we have the ability to increase the amount of information associated with a user.
Out of the box, WordPress stores a minimal set of user metadata, all of which can be seen in the administration screen or the database.
But let's say you want to get more information on a user. Perhaps you want more information about their social profiles, more information about their involvement in other projects, or you want to associate them with another service.
All of this is achievable using user metadata.
Comment metadata isn't any different than the type of metadata that we've discussed thus far. That is, you can easily take extra information and associate it with existing comment metadata.
Interestingly enough, WordPress has a blank table for this information upon an initial installation; however, it's empty:
But the fact that the API exists and the database table is available is enough to show that there's support for capturing more information about those who offer to voice their feedback for a given post.
In a future article, we're going to take a look at the various ways we can incorporate this into our work. Sometimes, it will involve thinking outside the box (the comment box, that is—okay, terrible pun).
The newest addition to the metadata family of APIs is that of Term Metadata. Here's the thing: Understanding how to use term metadata is predicated on the idea that you have a solid understanding of taxonomies, terms, and their relationships.
And for some reasons, the least of which is not how these particular components of WordPress have been named, people have a hard time grokking this information.
In an upcoming article, we're going to take a deep dive into all of this information to make sure that you have a complete understanding as to what taxonomies are, what terms are, how they are related, and how metadata can play a role in expanding this type of information.
It's easy to see that we've our work cut out for us.
Clearly, this is nothing more than an introduction as to where this series is going to head, but I'm excited about it. In the remaining three posts, we'll cover the aforementioned APIs, and we'll talk about how to use them to our advantage when working with more complex WordPress applications.
Specifically, we'll look at the APIs that are available, how to use them in the context of projects, and some steps we should take in order to secure and validate the information coming into the database (and being retrieved from the database) so those who are using our sites are doing so in a safe manner.
I'm looking forward to continuing with another series on how to do some slightly more advanced tasks with WordPress. Remember if you're just getting started, you can check out my series on how to get started with WordPress which is geared specifically towards WordPress beginners.
In the meantime, if you're looking for other utilities to help you build out your growing set of tools for WordPress, don't forget to see what we have available in Envato Market.
Finally, you can catch all of my courses and tutorials on my profile page, and you can follow me on my blog and/or Twitter at @tommcfarlin where I talk about software development in the context of WordPress.
As usual, please don't hesitate to leave any questions or comments in the feed below, and I'll aim to respond to each of them.