我的自定义函数:
/**
* Prints out one specified field from settings section.
*
* Based on:
* @see do_settings_sections
*
* @global array $wp_settings_sections Storage array of all settings sections added to admin pages
* @global array $wp_settings_fields Storage array of settings fields and info about their pages/sections
*
* @param string $page The slug name of the page whose settings sections you want to output
* @param string $field_id Field ID for output
*/
public static function do_settings_section_field($page, $field_id) {
global $wp_settings_sections, $wp_settings_fields;
if ( ! isset( $wp_settings_sections[$page] ) )
return;
foreach ( (array) $wp_settings_sections[$page] as $section ) {
if ( $section[\'callback\'] )
call_user_func( $section[\'callback\'], $section );
if ( ! isset( $wp_settings_fields[$page][$section[\'id\']] ) )
continue;
foreach ( (array) $wp_settings_fields[$page][$section[\'id\']] as $field ) {
if ( $field[\'id\'] !== $field_id )
continue;
call_user_func($field[\'callback\'], $field[\'args\']);
}
}
}
您可以使用此函数代替
do_settings_sections()
, 具有与第二个参数相同的第一个参数和渲染字段ID。