Extending the WordPress metadata API

The WordPress metadata API is a simple way to store and retrieve information related to various objects in WordPress, such as posts, users, and taxonomy terms. Out of the box, WordPress includes post meta, user meta, and term meta, but what if you want metadata on other objects, such as custom objects provided by a plugin? Thankfully, the metadata API is actually quite simple to extend, allowing developers to easily register their own kind of metadata that is attached to their own, custom objects.

code

Custom Database API – The Basic API Class

In the previous sections of this series, we have looked at reasons you should build a custom database API, we have discussed how to structure your data, and we have looked at how to create the database tables. Now it is time to build the basic API that we will use to actually interact with our database. This will involve writing an API class with all of the necessary methods for retrieving, inserting, updating, and deleting data.

series-custom-database-tables

Custom Database API – Creating the Tables

Once you have laid out the structure for your database table, it is time to create the actual tables. This is where it gets fun. When the tables are created, you can really begin building your API for interacting with the database and that’s when this whole project begins to truly take shape.

series-custom-database-tables

Batch processing for big data

When it comes to handling large amounts of data, there is really only one way to reliably do it: batch processing. The concept of batch processing is simple. Instead of performing one large query and then parsing / formatting the data as a single process, you do it in batches, one small piece at a time. If you have ever attempted to query or export a large amount of data and had your server timeout, you’ll easily understand just how beneficial batch processing is.

batch-processing

A look at the posts_where filter in WordPress

The WP_Query class in WordPress is extremely robust and allows you to construct just about any kind of query you need for retrieving data from the wp_posts table, but there are still scenarios you will encounter when building your plugins that WP_Query doesn’t support. Before WordPress 3.7, the posts_where filter was used primarily for setting up date-range queries and…

Template File Loaders in Plugins

Template files are very standard for themes and heavily used in child themes. For example, if a user wants to modify the layout of their site pages, they can simply copy page.php from their parent theme to a child theme, modify the HTML structure, and the changes will be reflected on the site. While it’s…

User Follow System – Part 7

In this final part of the User Follow System tutorial series, we will create two short codes, one for displaying a follow/unfollow link for a user and one for displaying a list of recent posts from users you (the currently logged-in user) follow. We will wrap up the series by also showing a few areas…

User Follow System – Part 6

In part 5 of this tutorial series we wrote the Javascript that is responsible for firing off the ajax events when a user is followed or unfollowed. Now, in this part, we are going to write the PHP side of the ajax events that takes care of processing the requests and sending a response back…

Error: Please enter a valid email address

Error: Invalid email

Error: Please enter your first name

Error: Please enter your last name

Error: Please enter a username

Error: Please enter a password

Error: Please confirm your password

Error: Password and password confirmation do not match