Simple technique to add custom meta box in WordPress admin dashboard

Wordpress Custom meta Post

The purpose of this plugin custom meta box in wordpress is to define some custom field which is not available in default post area. The most important feature of custom meta box in wordpress are stored in key value pair, so that we can easy to handle the data for searching or displaying.

The custom meta box can be added using

Parameters Explanation

• id [required] — Use this variable to add style for printing meta box, that is which is similar to HTML div id name. Through this id we can add style to the meta content to be displayed in webpage.

• title [required]— Name of the heading displaying in the post area.

• callback [required]— Business logics to be placed here

• post_type [required]— Location to place this custom box [‘post’, ‘page’, ‘dashboard’, ‘link’, ‘attachment’ or ‘custom_post_type’]

• context [optional]— The part of the page where the meta box should be shown for edit purpose

• priority [optional]— The priority in which your meta box should be shown

• callback_args [optional]— Arguments to pass into your callback function

After adding in admin dash board, we need to display in webpage for that we need to use this wordpress default function

  • Post_id – will get that particular post id
  • Key – string containing the name of the meta value you want
  • Single – It will be either TRUE or FALSE,  If true then the function will return a single result, as a string else the function returns an array of the custom fields

Ok, Let we check some example program to understand custom meta box in wordpress option better.

Consider, we are going to tell the difficulty level of our article using star value. For that we need to select the rating from the admin dashboard from value 1 to 5

1 – Normal
2 – Average
3 – Above Average
4 – Difficult
5 – Most Difficulty

Complete Program

Screen Shots

Post page rating view

Post difficulty mode admin view

Admin dashboard screen option



Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s