965

WPAlchemy MetaBox PHP Class

The WPAlchemy_MetaBox PHP class can be used to create WordPress meta boxes quickly. It will give you the flexibility you need as a developer, allowing you to quickly build custom meta boxes for your themes and plugins.

  1. Key Features and Benefits
  2. Defining a Meta Box is Easy
  3. Install and Setup (Video)
  4. Meta Box Setup Options
  5. The Guts of the Meta Box
  6. How to Use It! (show class methods)
  7. Repeating Field Groups
  8. Filter Specific Templates, Categories, Tags and Posts
  9. Using The Meta Box Values In Your Template
  10. Download
  11. Contribute

Key Features and Benefits

  • Easy to learn and integrate: good documentation and support is always important (I use the code myself and keep it up-to-date). Integration is a snap, as simple as including the class and using it.
  • Easy setup code: some of the details involved in saving, retrieving and working with the meta data are abstracted to ease development.
  • Flexible usage: the class acts as an aid for meta box development. By design you can use the class functions or your current development practices, which ever you feel most comfortable with for your development.
  • HTML and CSS separation: the HTML and CSS for your meta boxes remain separate from the core code, you can design your meta boxes to your liking, providing you the greatest flexibility during development.

Defining a Meta Box is Easy

// include the class in your theme or plugin
include_once 'WPAlchemy/MetaBox.php';

// include css to help style our custom meta boxes
add_action( 'init', 'my_metabox_styles' );

function my_metabox_styles()
{
	if ( is_admin() ) 
	{ 
		wp_enqueue_style( 'wpalchemy-metabox', get_stylesheet_directory_uri() . '/metaboxes/meta.css' );
	}
}

$custom_metabox = new WPAlchemy_MetaBox(array
(
	'id' => '_custom_meta',
	'title' => 'My Custom Meta',
	'template' => STYLESHEETPATH . '/custom/meta.php'
));

That’s it! The above code shows the basic definition needed to setup a custom meta box.

Tip Use WP_PLUGIN_DIR or WP_PLUGIN_URL if you are embedding wpalchemy in a custom wordpress plugin.

Install and Setup (Easy)

Tip Select 720 HD mode and watch it fullscreen or click the YouTube button to watch it on YouTube.

Setup Options

The following are the different setup options that you can use in the initial class setup array:

id

'id' => '_custom_meta'

Each meta box that you create requires an ID, this is the value that is saved into the wp_postmeta table. Starting your name with an underscore will effectively hide it from also appearing in the custom fields area.

title

'title' => 'Custom Meta'

This is the title of the meta box that appears in the WordPress UI.

template

'template' => STYLESHEETPATH . '/custom/meta.php'

You must define a template file for the contents of your meta box.

types

'types' => array('post','page')

This will default to post and page types, to add your meta box to custom post types you must define the types option.

context

'context' => 'normal'

The part of the page where the edit screen section should be shown (‘normal’, ‘advanced’, or ‘side’).

priority

'priority' => 'high'

The priority within the context where the meta box should show (‘high’ or ‘low’).

autosave

'autosave' => TRUE

Used to decide if meta box content should be autosaved.

mode

'mode' => WPALCHEMY_MODE_ARRAY // defaults to WPALCHEMY_MODE_ARRAY

Can be set to WPALCHEMY_MODE_ARRAY or WPALCHEMY_MODE_EXTRACT. Setting this option to WPALCHEMY_MODE_ARRAY (set by default) will cause the class to store all of its values as an associative array in a single meta entry. Setting this option to WPALCHEMY_MODE_EXTRACT will cause the class to extract all the first tier variables (fields) and create individual meta entries in the wp_postmeta table. This article has more info on this option.

prefix

'prefix' => '_my_' // defaults to NULL

When the mode option is set to WPALCHEMY_MODE_EXTRACT, you have to take care to avoid name collisions with other meta entries. The easiest way to do this is to add a prefix to your variables. This article has more info on this option.

Exclude / Include Options

exclude_… and include_…

exclude_template
exclude_category_id
exclude_category
exclude_tag_id
exclude_tag
exclude_post_id
include_template
include_category_id
include_category
include_tag_id
include_tag
include_post_id

Read more about Filtering Specific Templates, Categories, Tags and Posts

Action / Filter Options

init_action

'init_action' => 'my_init_action_func' // defaults to NULL

Callback used on the WordPress “admin_init” action, the main benefit is that this callback is executed only when the meta box is present.

output_filter

'output_filter' => 'my_output_filter_func' // defaults to NULL

Callback used to override when the meta box gets displayed, must return TRUE or FALSE to determine if the meta box should or should not be displayed.

save_filter

'save_filter' => 'my_save_filter_func' // defaults to NULL

Callback used to override or insert meta data before saving occurs. The callback function gets passed two parameters: $meta (first param) meta box data array and $post_id (second param). You can also halt saving by returning FALSE.

save_action

'save_action' => 'my_save_action_func' // defaults to NULL

Callback used to execute custom code after saving. The callback function gets passed two parameters: $meta (first param) meta box data array and $post_id (second param).

head_filter

'head_filter' => 'my_head_filter_func' // defaults to NULL

Callback used to insert content into the <head> tag. Also used to override or insert <style> or <script> tags into the head.

head_action

'head_action' => 'my_head_action_func' // defaults to NULL

Callback used to insert content into the <head> tag.

foot_filter

'foot_filter' => 'my_foot_filter_func' // defaults to NULL

Callback used to insert content into the footer. Also used to override or insert <script> tags into the footer.

foot_action

'foot_action' => 'my_foot_action_func' // defaults to NULL

Callback used to insert content into the footer.

Display Options

hide_editor

'hide_editor' => TRUE // defaults to NULL

Used to hide the default content editor in a page or post.

hide_title

'hide_title' => TRUE // defaults to NULL

Used to hide the meta box title.

lock

'lock' => WPALCHEMY_LOCK_TOP // defaults to NULL

Used to lock a meta box in place, possible values are: “top”, “bottom”, “before_post_title”, “after_post_title”, it is recommened that you use the following constants to set the value of this option: WPALCHEMY_LOCK_TOP, WPALCHEMY_LOCK_BOTTOM, WPALCHEMY_LOCK_BEFORE_POST_TITLE, WPALCHEMY_LOCK_AFTER_POST_TITLE.

Using WPALCHEMY_LOCK_BEFORE_POST_TITLE or WPALCHEMY_LOCK_AFTER_POST_TITLE allows you to prevent other meta boxes from being dragged and dropped above or below your custom meta box. This is really useful when you are not using the editor (e.g. its hidden) and you want to have your own custom fields always at the top.

view

'view' => WPALCHEMY_VIEW_ALWAYS_OPENED // defaults to NULL

Used to set the initial view state of the meta box, possible values are: “opened”, “closed”, “always_opened”, it is recommended that you use the follwing constants to set the value of this option: WPALCHEMY_VIEW_START_OPENED, WPALCHEMY_VIEW_START_CLOSED, WPALCHEMY_VIEW_ALWAYS_OPENED.

hide_screen_option

'hide_screen_option' => TRUE // defaults to NULL

Used to hide the show/hide checkbox option from the screen options area.

The Guts of the Meta Box

You probably noticed that the actual contents of the meta box come from the meta.php file. I’ve decided to leave the meta box content definition up to you vs having the class create form fields (this should give a you more freedom to manipulate the meta box contents to your liking).

Lets review the different parts to this solution, first off the meta.php:

[+ show code]

How to Use It!

All of the functions in this class are very WordPress friendly. If you are familiar with the WordPress Loop, you should have no problem using this class.

When working on your meta box template file (meta.php) there are a few variables available to you:

$post; // this is the current post, use $post->ID for the current post ID
$metabox; // this is the meta box helper object
$mb; // same as $metabox, a shortcut instead of writing out $metabox
$meta; // this is the meta data

Lets go over the different functions available in the class and how to use them. Important: you should refer to the meta.php HTML example above by using the line numbers given below. This should help you see the code in action.

the_field($name)

Use this function to set the current working field:

<?php $metabox->the_field('description');

the_name([$name])

This function will print the form field name. If you’ve set the current working field with the_field($name) then you can simply do the following:

$metabox->the_name();

If you have not set the current working field prior to calling this function, you can manually pass in a field’s name:

$metabox->the_name('name');

get_the_name([$name])

Same as the_name([$name]) except that it returns a value instead of printing out the value.

the_value([$name])

Use this function to get the current value of the field.

$metabox->the_value();

If you have not set the current working field prior to calling this function, you can manually pass in a field’s name:

$metabox->the_value('name');

get_the_value([$name])

Same as the_value([$name]) except that it returns a value instead of printing out the value.

if ($metabox->get_the_value() == '_self') echo $selected;

the_index()

Used inside have_fields() and have_fields_and_multi() to print the current index number.

get_the_index()

Same as the_index() except that it returns a value instead of printing out the value.

is_first()

Used inside have_fields() and have_fields_and_multi() to check if the field group is the first field group. When using the_group_open() and the_group_close(), the first HTML element will automatically have a css class of first.

is_last()

Used inside have_fields() and have_fields_and_multi() to check if the field group is the last field group. When using the_group_open() and the_group_close(), the last HTML element will automatically have a css class of last.

is_value([$value])

Uses to check the existence of a value.

<input type="radio" name="<?php $mb->the_name(); ?>" value="admin"<?php echo $mb->is_value('admin')?' checked="checked"':''; ?>/> Admin

The above would be equivalent to:

<input type="radio" name="<?php $mb->the_name(); ?>" value="admin"<?php echo ($mb->get_the_value() == 'admin')?' checked="checked"':''; ?>/> Admin

have_fields($name,$length)

This function is used during a loop. It helps you create multiple instances of a field or group of fields.

while($metabox->have_fields('authors',3))

Inside of the loop you can use the_name() and the_value() to help you define your form fields.

<?php while($metabox->have_fields('authors',3)): ?>
<p>
	<input type="text" name="<?php $metabox->the_name(); ?>" value="<?php $metabox->the_value(); ?>"/>
</p>
<?php endwhile; ?>

The above is equivalent to writing:

<p>
	<input type="text" name="_custom_meta[authors][0]" value="<?php if(!empty($meta['authors'][0])) echo $meta['authors'][0]; ?>"/>
</p>
<p>
	<input type="text" name="_custom_meta[authors][1]" value="<?php if(!empty($meta['authors'][1])) echo $meta['authors'][1]; ?>"/>
</p>
<p>
	<input type="text" name="_custom_meta[authors][2]" value="<?php if(!empty($meta['authors'][2])) echo $meta['authors'][2]; ?>"/>
</p>

Another really cool thing you can do with have_fields($name,$length), is to define field groups like the following representation:

_custom_meta[links][0][title]
_custom_meta[links][0][url]
_custom_meta[links][0][nofollow]
_custom_meta[links][0][target]
<?php while($metabox->have_fields('links',5)): ?>
<p>
	<?php $metabox->the_field('title'); ?>
	<input type="text" name="<?php $metabox->the_name(); ?>" value="<?php $metabox->the_value(); ?>"/>

	<input type="text" name="<?php $metabox->the_name('url'); ?>" value="<?php $metabox->the_value('url'); ?>"/>

	<br/><?php $metabox->the_field('nofollow'); ?>
	<input type="checkbox" name="<?php $metabox->the_name(); ?>" value="1"<?php if ($metabox->get_the_value()) echo ' checked="checked"'; ?>/> Use <code>nofollow</code>

	<?php $selected = ' selected="selected"'; ?>

	<br/><?php $metabox->the_field('target'); ?>
	<select name="<?php $metabox->the_name(); ?>">
	<option value=""></option>
	<option value="_self"<?php if ($metabox->get_the_value() == '_self') echo $selected; ?>>_self</option>
	<option value="_blank"<?php if ($metabox->get_the_value() == '_blank') echo $selected; ?>>_blank</option>
	<option value="_parent"<?php if ($metabox->get_the_value() == '_parent') echo $selected; ?>>_parent</option>
	<option value="_top"<?php if ($metabox->get_the_value() == '_top') echo $selected; ?>>_top</option>
	</select>
</p>
<?php endwhile; ?>

have_fields_and_multi($name[, $options])

This function is similar to have_fields($name,$length). You will notice that it does not use the $length parameter. But it provides additional functionality. It allows you to setup a custom “add” HTML element that can be used to create unlimited copies of your field or field group.

The $options param is an associative array which can contain the following values (each being optional).

$options = array('length' => 3, 'limit' => 10);

length: is the number of field groups to display initially (a minimum of sorts).

limit: is the hard limit at which point the “add new link” will stop working.

A simple example would be a meta box for adding a list of links: you may have two fields, one for a title and the other for a URL, using the features of the class you can easily setup an “add new link” button which would automatically spawn new instances of the field group you defined. Basically, clicking the “add new link” button again would spawn another field group, and so on.

The following is an example of using this function:

<h4>Documents</h4>

<a style="float:right; margin:0 10px;" href="#" class="dodelete-docs button">Remove All</a>

<p>Add documents to the library by entering in a title, 
URL and selecting a level of access. Upload new documents 
using the "Add Media" box.</p>

<?php while($mb->have_fields_and_multi('docs')): ?>
<?php $mb->the_group_open(); ?>

	<?php $mb->the_field('title'); ?>
	<label>Title and URL</label>
	<p><input type="text" name="<?php $mb->the_name(); ?>" value="<?php $mb->the_value(); ?>"/></p>
	
	<?php $mb->the_field('link'); ?>
	<p><input type="text" name="<?php $mb->the_name(); ?>" value="<?php $mb->the_value(); ?>"/></p>

	<?php $mb->the_field('access'); ?>
	<p><strong>Access:</strong>
		<input type="radio" name="<?php $mb->the_name(); ?>" value="admin"<?php echo $mb->is_value('admin')?' checked="checked"':''; ?>/> Admin
		<input type="radio" name="<?php $mb->the_name(); ?>" value="editor"<?php echo $mb->is_value('editor')?' checked="checked"':''; ?>/> Editor
		<input type="radio" name="<?php $mb->the_name(); ?>" value="subscriber"<?php echo $mb->is_value('subscriber')?' checked="checked"':''; ?>/> Subscriber
		
		<a href="#" class="button" style="margin-left:10px;" onclick="jQuery(this).siblings().removeAttr('checked'); return false;">Remove Access</a>
		<a href="#" class="dodelete button">Remove Document</a>
	</p>

<?php $mb->the_group_close(); ?>
<?php endwhile; ?>

<p style="margin-bottom:15px; padding-top:5px;"><a href="#" class="docopy-docs button">Add Document</a></p>

the_group_open([$tag])

This function is used to create a container element around your fields, by default the HTML tag used is a DIV. The HTML element will be printed out.

<?php $mb->the_group_open(); ?>

get_the_group_open([$tag])

Same as the_group_open([$tag]) except that it returns a value instead of printing out the value.

the_group_close()

This function is used to close the container element around your fields. The HTML element will be printed out.

<?php $mb->the_group_close(); ?>

get_the_group_close()

Same as the_group_close() except that it returns a value instead of printing out the value.

Creating an “Add” Button

This button is used to create new instances of your field or field group. Adding a docopy-GROUPNAME css class to an HTML element will make it clickable. GROUPNAME is the name you used in the have_fields_and_multi($name) function.

<p><a href="#" class="docopy-docs button">Add Document</a></p>

Creating a “Delete” Button

This button is used to remove and instance of your field or field group. Adding a dodelete css class to an HTML element will make it clickable. This button has to be between the_group_open() and the_group_close().

<a href="#" class="dodelete button">Remove Document</a>

Creating a “Delete All” Button

This button is used to remove all instances of your field or field group. Adding a dodelete-GROUPNAME css class to an HTML element will make it clickable. This button does NOT have to be between the_group_open() and the_group_close(). GROUPNAME is the name you used in the have_fields_and_multi($name) function.

<a href="#" class="dodelete-docs button">Remove All</a>

The “remove” and “remove all” buttons are optional. You can still delete fields by simply deleting their values and clicking the post “Update” button. Important: Adding and removing elements will always require you to click the post “Update” button.

Filter Specific Templates, Categories, Tags and Posts

I often find myself creating meta boxes which apply to a specific template or post. With this class, you to filter your meta boxes a few different ways: by template file, category_id, category name/slug, tag_id, tag name/slug and post_id.

When creating a new WPAlchemy_MetaBox instance the following options are available:

exclude_template
exclude_category_id
exclude_category
exclude_tag_id
exclude_tag
exclude_post_id
include_template
include_category_id
include_category
include_tag_id
include_tag
include_post_id

When assigning values to these options you can assign a value as a single value, an array, or a comma separated list. You will see usage examples below.

You can use as many options to achieve the results you want. Use the exclude options exclusively or the include options exclusively or combine them both for more advanced filtering.

It might be helpful to keep the following in mind: the excluding and including will be processed in the order listed above, excludes are processed first and then includes are processed, additionally templates come before categories which come before tags which come before posts.

Using Exclude Options

The exclude options allow you to exclude a template, category, tag, or post from displaying the meta box.

The following example excludes the “product” template from displaying the meta box, however all other templates will display the meta box.

new WPAlchemy_MetaBox(array
(
	'id' => '_custom_meta',
	'title' => 'My Custom Meta',
	'template' => STYLESHEETPATH . '/custom/meta.php',
	'exclude_template' => 'product.php'
));

Using Include Options

The include options allow you to only include a template, category, tag, or post to display the meta box.

This is different from the exclude option, as only the item that you specify will display the meta box, everything else would be excluded.

In the following example, pages that use the “product” and “press” templates will be the only pages that display the meta box, all other templates would not display the meta box.

new WPAlchemy_MetaBox(array
(
	'id' => '_custom_meta',
	'title' => 'My Custom Meta',
	'template' => STYLESHEETPATH . '/custom/meta.php',
	'include_template' => array('product.php','press.php') // use an array for multiple items
	// 'include_template' => 'product.php,press.php' // comma separated lists work too
));

Using Both Exclude and Include Options

For the most part you will do fine using exclude and include options separately from each other.

When you use exclude and include options together the include option will override any exclude options. Knowing this you can do some advanced filtering.

The following example will exclude all pages that use the “product” template except for a specific product page.

new WPAlchemy_MetaBox(array
(
	'id' => '_custom_meta',
	'title' => 'My Custom Meta',
	'template' => STYLESHEETPATH . '/custom/meta.php',
	'exclude_template' => array('product.php'),
	'include_post_id' => 85
));

More Exclude and Include Examples

The following filters your meta box to posts which have the “download” tag or is post_id 97

new WPAlchemy_MetaBox(array
(
	'id' => '_custom_meta',
	'title' => 'My Custom Meta',
	'template' => STYLESHEETPATH . '/custom/meta.php',
	'include_tag' => 'download',
	'include_post_id' => 97
));

The following filters your meta box by excluding it from several specific posts, unless those posts have a the “download” tag

new WPAlchemy_MetaBox(array
(
	'id' => '_custom_meta',
	'title' => 'My Custom Meta',
	'template' => STYLESHEETPATH . '/custom/meta.php',
	'exclude_post_id' => array(45,48,56,57,88,91,92,93)
	'include_tag' => 'download'
));

The following filters your meta box to posts that belong to the “WordPress” category

new WPAlchemy_MetaBox(array
(
	'id' => '_custom_meta',
	'title' => 'My Custom Meta',
	'template' => STYLESHEETPATH . '/custom/meta.php',
	'exclude_category' => 'WordPress',
	// 'exclude_category_id' => 12 // using category IDs also work
));

Using The Meta Box Values In Your Template

Using meta box values in your templates is just as straight forward, in your template file you would do something like the following:

// usually needed
global $custom_metabox;

// get the meta data for the current post
$custom_metabox->the_meta();

// set current field, then get value
$custom_metabox->the_field('name');
$custom_metabox->the_value();

// get value directly
$custom_metabox->the_value('description');

// loop a set of fields
while($custom_metabox->have_fields('authors'))
{
	$custom_metabox->the_value();
}

// loop a set of field groups
while($custom_metabox->have_fields('links'))
{
	$custom_metabox->the_value('title');

	$custom_metabox->the_value('url');

	if ($custom_metabox->get_the_value('nofollow')) echo 'is-nofollow';

	$custom_metabox->the_value('target');
}

In the code above, $custom_metabox is the object variable you created in functions.php when you used new WPAlchemy_MetaBox.

Again, you are not limited to having to use the class functions, you can use the default WordPress function get_post_meta() as such:

// instead of using helper functions, you can also use ...
$meta = get_post_meta(get_the_ID(), $custom_metabox->get_the_id(), TRUE);

// or ... (same as above)
// $meta = $custom_metabox->the_meta();

echo $meta['name'];
echo $meta['description'];

foreach ($meta['authors'] as $author)
{
	echo $author;
}

foreach ($meta['links'] as $link)
{
	echo $link['title'];
	echo $link['url'];
	if ($link['nofollow']) echo 'is-nofollow';
	echo $link['target'];
}

Download

WPAlchemy MetaBox Class, this project is on github

Contribute

Are you using this class? If so, become a contributor to it’s growth and stability. If you have problems using it, definitely let me know (I like to write and use stable code). Equally, if you have ideas to make it even better, I want to hear that too.

965 responses to “WPAlchemy MetaBox PHP Class”

  1. Joseph

    How can I dynamically replace ‘a’, ‘b’, ‘c’ in the array with the titles of a post type?

    have_fields(‘cb_ex’, count($items))): ?>

    get_the_index()]; ?>

    <input type="checkbox" name="the_name(); ?>” value=””the_checkbox_state($item); ?>/>

  2. Derek Damko

    @Dimas Here is a problem I am running into and I just cannot seem to get my head around it. I want to create a repeatable WP rich text editor using WPAlchemy but when I add a new editor it looks fine but I cannot click in the ‘textarea’ and add text. If I refresh or click Update on the page the new editor disappears. Here is my code:

    	while($mb->have_fields_and_multi('blocks')):
    	$mb->the_group_open();
     
    		$mb->the_field('content');
    		wp_editor($mb->get_the_value(), "editor_" . rand(1, 200), array("textarea_rows" => 10, "textarea_name" => $mb->get_the_name(), "editor_class" => "custom_editor"));
    		Remove Block
    		
            $mb->the_group_close();
    	endwhile;
    	Add Block
    

    You can see I am using the new ‘wp_editor()’ function in WP 3.3. Maybe I need to be doing it a different way. Any thoughts or suggestions? Thanks.

  3. Brokenflipside

    @dimas or @anyone! Help! I have not modified the class AT ALL and I am getting this error when I migrate to the live server:

    Fatal error: Cannot use string offset as an array in /MetaBox.php on line 1637

  4. Brokenflipside

    @dimas ok, whew I over reacted for a second. After a breath I began investigating at a more macro scale and realized the error was directly related to my importing of the old servers post data through standard import option.

    I will recreate the scenario tomorrow and post specifics. Yes I am using the most recent version. The error was being thrown whenever data from the dynamically rendered fields was being called. Though come to think of it all my data that is not from a dynamically rendered set of fields is not using wpalchemy…

  5. Brokenflipside

    @dimas ok, whew I over reacted for a second. After a breath I began investigating at a more macro scale and realized the error was directly related to my importing of the old servers post data through standard import option.

    I deleted the imported data and started fresh, everything worked fine from here on out.

    I will recreate the scenario tomorrow and post specifics. Yes I am using the most recent version. The error was being thrown whenever data from the dynamically rendered fields was being called. Though come to think of it all my data that is not from a dynamically rendered set of fields is not using wpalchemy…

  6. Jonathan Liuti

    @Dimas : please switch to google group (or something alike) and close the comments here, each time I’m looking for some infos I’m loosing so much time getting my hands back on it. Setting up a google group is easy and I’m sure I’m not the only one who would like to see that happen.

    Also, why don’t you use the wiki on github for documentation so everyone can contribute with code example and share their use cases ?

    If you want any help let me know, I’d be glad to help but You are the one in charge here ;-)

    Bests.

  7. Jonathan Liuti

    @Dimas, you are the man ! Looking forward to see this :-)

    Thanks for your time !

  8. Jaco

    @Dimas, first off, thanks for a great plugin – it has revolutionised my custom posts.

    A question for which I can’t seem to find the answer: how do I access WPAlchemy’s meta data to use in a WP_Query?

    I have an events post type and want to select or exclude and order posts based on their start date, which is captured via an input:text form type in the post type’s metabox.

    Any suggestions or perhaps a pointer to where to find a doc about this?

    Thanks for your hard work.

  9. Jaco

    Hi Dimas – I found the answer – apologies for wasting your time. When you sit coding and researching at midnight after 3 hours of sleep the night before, things sometimes seem impossible to find.

    After doing a site:farinspace.com wp_query search, I found
    http://www.farinspace.com/wpalchemy-metabox-data-storage-modes/

    It has solved my problems, thank you very much :)

  10. Melinda

    @dimas or @anyone Does anyone know how to get a thumbnail of the image you selected to show up in your metabox? I have integrated the wordpress media uploader to select images for a gallery and I want a thumbnail of each image to display so the client can easily reorder the images using the sorting method for metaboxes that was shown on this site. I just can’t seem to figure out how get the thumbnail to display.
    Your help is greatly appreciated!

  11. Joseph

    This is what I did to show a thumbnail of the image selected:
    I added this line to my metabox php file.

    <img src="get_the_value(); ?>” style=”width:100px;height:100px” />

    That will show thumbnails for all boxes to make it easy to reorder, and it works fine.

    The only issue is that you have to update the post before you can see the image, I don’t know how to show the image as soon as its selected, I think its Ajax that can have this done. Is its possible to get help on this.

  12. David

    Hi,

    I’ve been playing around with this and I think I seem to grasp it (noob of a coder), but I wanted to know. How would I pull the data from my meta boxes in to the admin columns when viewing all CPT’s?

1 37 38 39