In this tutorial, we  will show you how to add custom meta fields to custom taxonomies in WordPress. This article brought our attention to another important topic of how to add custom meta boxes in WordPress pages, posts and post types. We have linked to some good tutorials that showed how to do add custom meta boxes in WordPress from our article however all those are no longer available. Therefore in this article, we will show you how to add custom meta boxes in WordPress pages, posts and custom post types.Because the goal of this article is to show you how to create reusable meta boxes in WordPress, we will be utilizing a Custom Metaboxes and Fields for WordPress class (CMB)

First thing you need to do is to create a new folder and call it “custom-metaboxes”. Extract the CMB zip files in here.

Now let’s create a blank PHP file, and call it “custom-metabox.php”. This is the file that we will use to define to create all the meta boxes that we need. Below is an example content that you can place in this file:

Meta Boxes'pages' => array('page')

  • page‘ – a page.
  • post‘ – a post.
  • Custom Post Types

The below example is very basic to add a sample test meta box with a text field and WYSIWYG  on “pages”.  As you can see, that you have the option to customize the post type, and just about everything.

CMB class supports the following field types:

  • text
  • text small
  • text medium
  • text money
  • date picker
  • date picker (UNIX time-stamp)
  • date time picker combo (UNIX time-stamp)
  • time picker
  • color picker
  • text area
  • text area small
  • text area code
  • select
  • radio
  • radio inline
  • taxonomy radio
  • taxonomy select
  • checkbox
  • multi check
  • Image/file upload

Once you are done, upload the file in your metabox folder and include the file in your “functions.php”
require get_stylesheet_directory() . '/custom-metaboxes/custom-metabox.php';

Now, you can easily see these fields in your pages, posts and custom post types.

One response to “How to Add Custom Meta Boxes in WordPress Page, Posts and Post Types”

  1. This is really helpful to used my business site development. I absolutely like this tutorial. well explained. Thanks,

Leave a Reply


Your email address will not be published. Required fields are marked *

Reload Image

Find us on Facebook

Subscribe to our Newsletter