add_meta_box : Pass Params to Callback?
-
Hello Community,
I need to pass some Params to “my_callback”:
<?php add_meta_box( $id, $title, ‘my_callback’, $page, $context, $priority ); ?>First try was something like this:
function my_callback() { global $params; } function add_my_meta_box() { global $param; $param = 'somevalue'; add_meta_box( $id, $title, <strong>'my_callback'</strong>, $page, $context, $priority ); }
Did not work…
Next try was to wrap it up in a Class to pass the params like
$this->param = 'somevalue';
Good plan, but when it came to my_callback, I tried something like'my_class::my_callback' or array ($this, 'my_callback') or '$this->my_callback()'
Yes, I know, some things I tried are stupid, but I did… so what…
I finally came up with
$_SESSION['MYPARAM'] = 'somevalue';
At least, it works. But I don′t like it.
Is there any way to pass params to my_callback, or use add_meta_box from within a class?Thanks in advance!
Best regards
Udo
Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
- The topic ‘add_meta_box : Pass Params to Callback?’ is closed to new replies.