WordPress Meta Boxes and Options Pages «on the fly»

Ready-to-use and fast PHP class, it allows you to create metaboxes for posts and taxonomies, it also allows you to create your own options pages or you can add additional settings to default options pages, e.g General or Writing.

The Fastest Metabox Plugin

You know, I'm not just saying that. One of my subscribers provide me the performance test result he made. You can find it here

Default input fields - text, checkbox, textarea, select, radio buttons for WordPress Pages.

Taxonomies Support

In WordPress 4.4 the wp_termmeta table was intruduced. It means that now we can easily create additional settings for each taxonomy term.

Add image uploader field in tags

Option Pages Support

Create new settings pages or add options to the existing ones, like «General», «Writing», «Reading» etc.

Add settings fields to the General Settings page

No GUI

This plugin is for creating user interfaces, but it doesn't mean that it should have its own UI - one of the reasons why the plugin is so fast. Basic PHP knowledge required.

$option = array(
	// ID of the metabox and custom field name prefix
	'id'	=>	'test1',
 
	// Only users with this capability can see and use the metabox
	'capability' =>	'edit_posts',
 
 	// Title of the metabox DIV
	'name'	=>	'Default input fields',
 
	// Custom post types names
	'post_type'	=>	array('post', 'page'),
 
	// array of fields, in this example it is only text field
	'args'	=>	array( 
		array(
			'id'	=> 'textexample',
			'label' => 'Text',
			'description' => 'Text field description, <code>HTML</code> tags are supported',
			'type'	=> 'text', // "text", "checkbox", "textarea", "radio" etc etc
			'placeholder' 	=> 'Placeholder'
		)
	)
);
 
// just pass options here and that's all - metabox is created
if ( class_exists( 'trueMetaBox' ) ) new trueMetaBox( $option );

Support

I'm always here if you need my help.
Please leave your question here or contact me if you need assistance with the plugin.

Default input fields - text, checkbox, textarea, select, radio buttons for WordPress Pages.

  • No GUI, everything can be configured directly via PHP class arguments
  • The Fastest Metabox Plugin, read more
  • Add your options to default WP options pages, e.g. Settings > General
  • Custom post types and taxonomies are supported
  • Supported fields: text inputs, radio, checkboxes, selects, textareas, image and file uploaders, colorpicker, TinyMCE/Quicktags editor, multiselect, google maps, YouTube/Vimeo videos.

It is time to share with you my own working solution.

Meta Boxes and Option pages are the things the developers work with very often. Many of developers use ready plugins for these purposes, some of them write the code by themselves.

Why using another ready plugins is not a good idea? I had a chance to work with some of them (I do not want to say their names here) and they were veeery slooow.

  • First — the most of the ready plugins are creating the custom post type just for metabox settings!
  • Second — the developers of such plugins tried to do everything as beautiful as it can be even if it makes the WordPress dashboard twice slower.

Why writing the code by yourself each time is not a good idea? When you create meta boxes in the code, how you do it? Do you open a bookmark with tutorial in your browser or copy the meta boxes code from your previous project or write each line of code again?

In all of these cases my plugin will save you much time.

Ready-to-use Examples

To make the following examples work all you need is to download and install my plugin on your WordPress website. After that just copy the code from examples and insert it to your theme functions.php file. That’s it.

Example 1. Default input fields

I mean here input[type="text"], input[type="checkbox"], textarea, select and input[type="radio"].

WordPress Metabox with common input fields - text, textarea, checkbox, select and radio buttons.
$options = array(
	array(
		'id'	=>	'test1', // ID of the metabox and custom field name prefix
		'capability'=>	'edit_posts', // Only users with this capability can see the metabox
 
		/* the following parameters are only for Custom Post Types usage */
		'name'	=>	'Default input fields', // MetaBox title
		'post_type'	=>	array('page'), // custom post types names
		'priority'	=>	'high', // low | high | default
 
		/* the following parameter is only for Taxonomies usage */
		'taxonomy'	=>	array('post_tag'),
 
		'args'	=>	array( // array of inputs
			/* simple text input */
			array(
				'id'	=> 'textexample',
				'label' => 'Text',
				'description' => 'Text field description, <code>HTML</code> tags are supported',
				'type'	=> 'text',
				'placeholder' 	=> 'Placeholder'
			),
 
			/* checkbox input */
			array(
				'id'	=> 'checkboxexample',
				'label' => 'Checkbox',
				'description' => 'Checkbox label, <code>HTML</code> tags are supported',
				'type'	=> 'checkbox'
			),
 
			/* textarea */
			array(
				'id'	=> 'textareaexample',
				'label' => 'Textarea',
				'description' => 'Textarea description, <code>HTML</code> tags are supported',
				'type'	=> 'textarea'
			),
 
			/* select */
			array(
				'id'	=> 'selectexample',
				'label' => 'Dropdown select field',
				'description' => 'Description, <code>HTML</code> tags are supported',
				'type'	=> 'select',
				'args'  => array('Name'=>'Value','Name 2'=>'Value 2')
			),
 
			/* radio input */
			array(
				'id'	=> 'radioexample',
				'label' => 'Radio buttons',
				'description' => 'Description of the radio buttons.',
				'type'	=> 'radio',
				'args'  => array('Radio button 1'=>'Value 1','Radio button 2'=>'Value 2')
			)
 
 
		)
	)
);
 
foreach ($options as $option) {
	$metabox = new trueMetaBox($option);
}
// if you want to add these settings not for posts but for terms,
// just change the name of the class to "trueTaxonomyMetaBox"

Example 2. Image and file uploaders

WordPress MetaBox with image and file uploaders
$options = array(
	array(
		'id'	=>	'test2', // metabox ID, this is also used as custom field prefix
		'name'	=>	'Metabox with image and file uploaders', // title
		'post_type'	=> array('page'), // post types
		'priority'	=> 'high', // low | high | default
		'capability'=>	'edit_posts', // capabilities the user should have to edit this metabox
		'args'	=>	array(
 
			array(
				'id'		=> 'image_example',
				'label'		=> 'Image',
				'description'	=> 'Under the upload button you can place a description.',
				'type'		=> 'image'
			),
 
			array(
				'id'		=> 'file_example',
				'label'		=> 'File upload',
				'description'	=> 'Description with <strong>HTML</strong> tags support',
				'type'		=> 'file'
			),
 
		)
	)
);
 
foreach ( $options as $option ) {
	$metabox = new trueMetaBox( $option );
}

Example 3. Colorpicker, TinyMCE/Quicktags editor, Multiselect by Chosen

Metabox with Colorpicker, Multiselect and WordPress TinyMCE/HTML editor
$options = array(
	array(
		'id'		=>	'test3',
		'capability'	=>	'edit_posts',
		'name'		=>	'Custom input fields',
		'post_type'	=>	array('page'),
		'priority'	=>	'high', // low | high | default
 
 
		'args'	=> array( // array of fields
 
			array(
				'id'		=> 'colorexample',
				'label'		=> 'Colorpicker',
				'description'	=> 'Color, begins with #.',
				'type'		=> 'color'
			),
 
			array(
				'id'		=> 'editorexample',
				'label'		=> 'TinyMCE + HTML',
				'description'	=> 'You can use 2 and more editors on the same page.',
				'type'		=> 'editor'
			),
 
			array(
				'id'	=> 'multiselectexample',
				'label' => 'Multiple select (Chosen based)',
				'description' => 'Description is here',
				'type'	=> 'multiselect',
				'args'  => array('Dombay'=>'dombay','Arhyz'=>'arhyz','Roza Khutor'=>'roza-hutor', 'Elbrus'=>'elbrus')
			)
 
		)
	)
);
 
foreach ($options as $option) {
	$metabox = new trueMetaBox($option);
}

Example 4. Google maps, videos from YouTube/Vimeo

WordPress Metabox with Google Maps and YouTube/Vimeo preview.
$options = array(
	array(
		'id'		=>	'test4',
		'capability'	=>	'edit_posts',
		'name'		=>	'Google Maps, YouTube, Vimeo',
		'post_type'	=>	array('post'),
		'priority'	=>	'high',
		'args'		=>	array(
 
			array(
				'id'		=> 'mapexample',
				'default_lat'   => '-25.363',
				'default_lng'   => '131.044',
				'label'		=> 'Google maps',
				'description'	=> 'You can add as much Google Maps on the same page as you want.',
				'type'		=> 'map'
			),
 
			array(
				'id'		=> 'videoexample',
				'label'		=> 'Video input field with preview',
				'description'	=> '',
				'type'		=> 'video'
			)
 
		)
	)
);
 
foreach ($options as $option) {
	$metabox = new trueMetaBox($option);
}

How to do the same in options pages

Custom options page with Google Maps in it created with the plugin.
/*
 * @MishaRudrastyh
 * website options
 */
$options = array(
	array(
		/*
		 * you can specify the slug of on eof the default options pages, "general" for example
		 */
		'slug'		=> 'mypage',
 
		/*
		 * title, menuname and capability are required only for new options pages
		 */
		'title' 	=> 'Options page title',
		'menuname'	=> 'More settings',
		'capability'	=> 'edit_posts',
		'sections' 	=> array(
 
			array(
				'id'	=> 'mysection', // if you do not want to create a section set "default" here
				'name'	=> 'Custom Section',
				'fields'=> array(
 
					array(
						'id'		=> 'mapexample',
						'default_lat'   => '-25.363',
						'default_lng'   => '131.044',
						'label'		=> 'Google Maps Example',
						'description'	=> 'Description is here.',
						'type'		=> 'map'
					)
 
				)
			)
 
		)
	)
);
 
 
if( class_exists( 'trueOptionspage' ) ) {
	foreach ($options as $option) {
		$trueoptions = new trueOptionspage($option);
	}
}

The other plugins comparison #

My blog reader compared my plugin (True Metabox) with popular Advanced Custom Fields and Toolset Types and sent me the result table (click to enlarge).

Compare my plugin speed with the other similar plugins.

Do you agree that it is much better to use my True Metabox plugin for good website performance?

For collecting this data he used the following piece of code.

function wp_usage(){
	printf( ('SQL: %d за %s сек. '), get_num_queries(), timer_stop(0, 3) );
	if ( function_exists('memory_get_usage') )
		echo round( memory_get_usage()/1024/1024, 2 ) . ' MB ';
}
add_filter('admin_footer_text', 'wp_usage');

1.1 – June 9, 2016

  • Added: Google Maps are now in the same language as the website.
  • Improved: Reduced the number of SQL queries in Dashboard.

1.0

  • Plugin release date.

Comments 8

  • Hi Misha!
    I ‘ve tested and used your Metabox plugin and I really like it a lot!
    I have used other plugins like Advanced Custom Fields etc. But from time to time
    I want to use a more straight on function for certain theme specific setting etc.
    and I think your plugin really do that job excellent, Really Great! Thanks!

  • Onur OztaskiranJanuary 9, 2017 at 17:01

    I’m a wordpress theme designer and have already used Misha’s snippets before. Now I tried a lot of meta box plugins out there esp premium ones.

    Not one of them is near this plugin!

    Highly recommended! It will be worth your 20 bucks so many times :)

  • Onur OztaskiranJanuary 9, 2017 at 11:01

    Hey Misha,

    I don’t have Paypal. Is there any other way I can buy with credit card?

    Thanks!

  • Are there any undocumented helper functions that return an array that can simply be passed to the args parameter of a select or multi-select option to more easily populate options with from the following sources?

    * All Public (Custom) Post Types
    * All Taxonomies
    * All Terms (for a given Taxonomy)
    * All Posts (for a given Post Type – Page, Post, Custom)

    The saved meta value would be the ID of the selected item.

    • MishaAuthorJanuary 5, 2017 at 20:01

      Hi,

      please, give me 1-2 days to add the mentioned functions to the new plugin version. I will notify you by email when the new version (1.2) will be available. After that you could easily update the plugin directly from your WordPress admin area.

      Thank you for suggestion.

      • Thank you for the reply!

        While I forgot the word “Public” in front Taxonomies in my previous comment, that’s what I meant.

        I figured there weren’t any such helpers but having now confirmed that, I will tell you that I just decided to write them myself yesterday to see how long it would take since I didn’t know when if ever to expect a response. It turned out to be pretty straightforward.

        All the functions I needed previously have now been written and do what I wanted. I tell you this to potentially avoid any duplication of work. These functions might even benefit from a refactor by yourself. If you’d like me to send them to you so you don’t have to start from nothing, send me an email using the one from this comment and I will reply. I don’t want to post them here. If you use them in any form in the core product, that’s fine.

        Thanks again! :-)

Leave your question or feedback

phpjsHTMLCSSSQLCode
Please, enter a comment
Please, enter a name
Incorrect email

14-Day Money Back Guarantee

Secure Checkout. Instant Download

Recommended

Advanced

$119 one-time payment
  • Lifetime priority support
  • Lifetime updates
  • Unlimited websites

Regular

$19 one-time payment
  • 2 weeks/support
  • 1 year/updates
  • Unlimited websites

View my refund policy here

The plugin is a one-time purchase which includes a license for plugin updates and support. To continue receiving updates & support after your license has expired you may renew at a discounted rate of 50%.