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. arimichi

    Hi,Dimas.
    First of all, please let me appreciate from the bottom of your heart.
    This plug-in is very wonderful. Please let me ask a question one.
    when the custom-made field of a picture is used within a custom post type, media-up-loader does not operate well.
    please let me know how to solve it.

    script blow.
    —-metabox.php
    the_field(‘imgurl’);
    $wpalchemy_media_access->setGroupName(‘nn’)->setInsertButtonLabel(‘insert’);
    ?>
    pictuer

    getField(array(‘name’ => $mb->get_the_name(), ‘value’ => $mb->get_the_value())); ?>
    getButton(); ?>

    —-setup.php
    ‘_custom_meta’,
    ‘title’ => ‘picture’,
    ‘template’ => get_stylesheet_directory() . ‘/metaboxes/metabox.php’,
    ‘types’ => array(‘xxxx’),
    ‘mode’ => WPALCHEMY_MODE_EXTRACT

    ));
    ?>

  2. MattStrange

    Hi Dimas,

    Within a ‘have_fields_and_multi’ group i have a select box with the following code:

    http://pastebin.com/wVACCXqn

    I want to be able to have the first option selected (+) rather than having a blank option and then the user has to select the desired option.. ive tried the following but this somehow causes issues and duplicates the group.

    http://pastebin.com/d5WdMn8W

    Any ideas?

    Kind Regards

  3. Birgit

    Hi Dimas,

    first of all, let me thank you for all the work you put in this. It’s well appreciated and it seems really helpful.

    However, I’m in trouble setting this up. I’ve just downloaded WP3.2.1 and followed your video tut, but the meta box doesn’t appear on the Edit Post screen. I’ve checked on all the directories and links. Does this work for the latest WP version?

    Hoping for your help. Thanks again :)

  4. Birgit

    never mind my previous post. found the solution. and thanks again for this great blog!

  5. Pedro

    Hello Dimas,

    is it possible to call a meta from the content of the post with a shortcode or something similar?

    Thanks

  6. Fingerflow

    Hi,

    Great job! Really usefull to customize wp!
    I’m wondering if it would be possible to repeat a repeatable bloc.
    I took a look at the core class and it seems not :)

    Anyway thanks for the piece of code and have a great day!

    Yassin

  7. dany

    If I have multiple metabox panels can I display all the values of a single metabox group in my theme?

  8. MattStrange

    Hi Dimas,

    Really enjoying working with this class, :)

    I looked through the previous comments and found out how to use the jquery datepicker for the repeating group fields, please take a look at the following code, the first code at pastie seems to work but for the first field only.

    http://pastie.org/3008196

    I then tried to bind the jquery with wpa_copy but this fails, notice the change in the jQuery…

    
    jQuery(function($) {
            $.wpalchemy.bind("wpa_copy", function(the_clone) {
                    $(".datepicker", the_clone).datepicker();
                    //console.log(the_clone);
            });
    });
    
    

    http://pastie.org/3008214

    Really not sure what i’m doing wrong :(

    Kind Regards

  9. Mamouneyya

    WP 3.3 is out! with this awesome new API:
    http://codex.wordpress.org/Function_Reference/wp_editor

    @Dimas A great time to cleanly add support for WYSIWYG fields ;)

  10. Francis

    Hi Dimas,

    Since I updated to WP 3.3, I have this error message:

    Notice: wp_enqueue_style was called incorrectly. Scripts and styles should not be registered or enqueued until the wp_enqueue_scripts, admin_enqueue_scripts, or init hooks. Please see Debugging in WordPress for more information.

    When I “deactivate” WPalchemy everything works fine :-/ I see it only when I have WP_DEBUG “on”… Tried it on different installs, different themes using WPalchemy and I have the same problem. No feedback about that problem ??

  11. eli

    the code you have in your video to show the meta info on a template isnt working. its not displaying anything not even if i add print_r

  12. antonio

    @eli,

    using the words “hello”, “please” and “thanks” might also help….

  13. kathy

    +1 @antonio!

    @eli : standard operating procedure when you want tech help from someone should include what you are trying to do, what you have tried (code examples) and what errors you are seeing instead of what you expect. and a little politeness goes a long way… especially when all the code AND help is given free of charge.

  14. Francis

    Thanks Dimas, it worked perfectly well :)

    I have another question for you: How can I display embedded videos using metaboxes ? I saw that you integrated the [embed] shortcode but don’t really know how to use it. :-/

    Thanks for your help :)

  15. Francis

    Thanks Dimas. Unfortunately, I went already on that page, tried everything but can’t make it work. It always display the URL of the video but not the video itself. I tried [embed]URL[/embed] but still does not work. Here is my problem. Don’t know how to get the right code to display these videos ^^

  16. Francis

    My code is really simple but I only get the URL:


    the_meta();
    ?>

    have_fields('vids')) {
    ?>
    the_value('videourl'); ?>

    I am sure I forget something simple but can’t get it ^^

  17. Francis

    Sorry about that, here is my code: https://gist.github.com/1477638

    Cheers,