New add_settings_field question
-
Hi all!
I’m amazed with this new add_settings_field thing. That’s awesome!!
But I’m trying to figure out how to pass an argument to the callback function. Actually, I don’t know if it could be done ??
Eg.
$as = array('A', 'B', 'C', 'D'); $adb = null; function my_new_settings(){ global $as; foreach($as as $a): $adb = sanitize_title($a); register_setting('media',"{$adb}_1"); register_setting('media',"{$adb}_2"); add_settings_field("{$adb}" , "{$a} setting:" , 'my_new_callback' , 'media' , 'default'); endforeach; } function my_new_callback(){ global $adb; echo "<label for=\"{$adb}_1\">Setting 1</label> <input name=\"{$adb}_1\" id=\"{$adb}_1\" value=\"".attribute_escape(get_option("{$adb}_1"))."\" class=\"small-text\" type=\"text\"> <label for=\"{$adb}_2\">Setting 2</label> <input name=\"{$adb}_2\" id=\"{$adb}_2\" value=\"".attribute_escape(get_option("{$adb}_2"))."\" class=\"small-text\" type=\"text\"> "; } add_action('admin_init', 'my_new_settings');
Could anyone help here?
Thanks in advance!
n!PS: I think this is a WP-Advanced Forum question but I can’t post there, does anyone know why it is closed to moderators?
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘New add_settings_field question’ is closed to new replies.