How to Create Custom WordPress Write/Meta Boxes

Creating meta boxes is a crucial part of WordPress theme/plugin development. It’s a way to add an appealing editor to the post screen and avoids forcing users to rely on custom fields. If you’ve ever created a custom post type in WordPress, you’ve probably wanted to add some sort of additional data to it. Sure, you could use custom fields, but that’s ugly. Getting started with custom meta boxes is easy, so let’s dive in!

What Are Custom Meta Boxes?

A custom meta (or write) box is incredibly simple in theory. It allows you to add a custom piece of data to a post or page in WordPress.

Imagine that you’re working on a theme for a client that wants to catalog his extensive collection of concert posters. You immediately start looking to the core WordPress functionality to see how you might organize the theme: Every post will represent a poster, which is perfect for adding an image, title and description. We can also use the categories and tags system inside of WordPress to organize the posters. But what if we wanted to add a new type of meta data for the “artist” of each poster? Hmph. WordPress doesn’t quite have anything for that right out of the box… which brings us to custom meta boxes.

A custom meta (or write) box is incredibly simple in theory. It allows you to add a custom piece of data to a post or page in WordPress – what’s better is that it can fit directly into most of the default pages inside WP, so you can easily place it inside the Post-Editor for easy use by non-technical types. As I said in the intro, you can add this same kind of “meta data” to your post using the built in custom fields for a post or page. There’s nothing wrong with this persay, but it’s not a very graceful or user-friendly.

https://code.tutsplus.com/tutorials/how-to-create-custom-wordpress-writemeta-boxes–wp-20336

  • Categories