
如何在WordPress中添加分页符并自定义样式?
do_settings_fields ( $page, $section )
do_settings_fields: 这是一个WordPress的函数,用于输出一组设置字段的HTML: 这个函数通常用于在WordPress管理中创建自定义设置页面。
打印出特定设置部分的设置字段。
设置API的一部分。在设置页面中使用它来输出一个特定的部分。通常应该由do_settings_sections()调用,而不是直接调用。
function do_settings_fields( $page, $section ) { global $wp_settings_fields; if ( ! isset( $wp_settings_fields[ $page ][ $section ] ) ) { return; } foreach ( (array) $wp_settings_fields[ $page ][ $section ] as $field ) { $class = ''; if ( ! empty( $field['args']['class'] ) ) { $class = ' class="' . esc_attr( $field['args']['class'] ) . '"'; } echo "<tr{$class}>"; if ( ! empty( $field['args']['label_for'] ) ) { echo '<th scope="row"><label for="' . esc_attr( $field['args']['label_for'] ) . '">' . $field['title'] . '</label></th>'; } else { echo '<th scope="row">' . $field['title'] . '</th>'; } echo '<td>'; call_user_func( $field['callback'], $field['args'] ); echo '</td>'; echo '</tr>'; } }