Let’s talk about post metadata. WordPress stores metadata for post’s content into its
wp_postmeta database table. When you need a piece of metadata that does not already exists, then you create a new custom field. Therefore, a custom field is nothing more than a post metadata that you specify. That’s it. Hint: You’ll learn how WordPress optimizes SQL queries to speed up your webpage loading.
What is a Custom Field?
A custom field is just a single piece of post metadata that you specify. It’s custom because you added it. It was not predefined or included in WordPress Core. Nope, you added it.
WordPress uses the word “custom” for this purpose and intent. Custom post type, taxonomy, and field are all classifications for the customization you add to a website.
Using a custom field plugin, e.g. CMB2, ACF, or others, merely gives you a snazzy GUI (interface) to interact with the custom field. I’ll show you in this episode.
In this episode, you’ll look at the sequence of the SQL queries that WordPress does when loading a page: grabs the post, then terms, and then all of the post metadata. The metadata is then cached. When you run
get_post_meta() for that post, it grabs it out of the cache. You’ll learn why.
You’ll also write the SQL queries to fetch the post metadata. You’ll look at custom fields. And you’ll write a quick subtitle custom field and render it out to the browser. You’ll even learn a little more SQL with the
If you listen carefully, you can hear the 1s and 0s flowing in your computer.
Total Lab Runtime: 02:08:59
- 1 Lab Introductionfree 05:17
- 2 The Big Picturepro 14:35
- 3 Your First SQL Querypro 12:21
- 4 WordPress to Database Relationshippro 20:20
- 5 Filter Content with WHEREpro 08:24
- 6 Table Alias with ASpro 05:08
- 7 Defining Table Structure (Schema)pro 12:17
- 8 Create a New Database Tablepro 10:23
- 9 WordPress Schemapro 05:11
- 10 Exploring WordPress Queries with Query Monitorpro 07:14
- 11 SQL to Get a Custom Fieldpro 16:41
- 12 SQL to Update Custom Fieldpro 05:14
- 13 Wrap it Upfree 05:54