thats exactly how you do it
What do you mean? $_SESSION variables or the my_callback($var1, $var2)?
If you haven’t figured it out yet, since v2.8 there’s another parameter you didn’t show, $callback_args
, i.e. here’s the function prototype:
add_meta_box($id, $title, $callback, $page, $context = 'advanced', $priority = 'default', $callback_args=null)
In your example passed an array containing your two variable’s values:
function add_my_meta_box() {
$var1 = "Blabla";
$var2 = "Something"
add_meta_box($id, $title, my_callback (<< Those 2 vars should be passed to this function), $page, $context, $priority, array('foo'=>$var1,'bar'=>$var2));
}
Then in your example it would look like this:
function my_callback ($post, $metabox) {
echo $metabox['args']['foo'];
echo $metabox['args']['bar'];
}
Hope this helps.
Awesome! Gonna use that with my latest project right away.
Thnx!
@mikeschinkel – Thanks, the documentation wasn’t great on the Codex. $post
, then $vars
!