Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- add_settings_field(
- 'category_options_select',
- 'Category',
- array( $this, 'category_options_select_callback' ),
- 'my-setting-admin',
- 'api_options',
- array (
- 'label_for' => 'Categories', // makes the field name clickable,
- 'name' => 'category', // value for 'name' attribute
- 'options' => array (
- '1' => '1',
- '2' => '2',
- '3' => '3',
- ),
- 'option_name' => 'test'
- )
- );
- function category_options_select_callback( $args )
- {
- printf(
- '<select name="%1$s[%2$s]" id="%3$s">',
- $args['option_name'],
- $args['name'],
- $args['label_for']
- );
- foreach ( $args['options'] as $val => $title )
- printf(
- '<option value="%1$s" %2$s>%3$s</option>',
- $val,
- selected( $val, $this->options['categories'], FALSE ),
- $title
- );
- print '</select>';
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement