WEBSITE & App Builder

Lorem Ipsum is simply dummy text of the printing and type setting industry. Lorem Ipsum has been the industry’s standard dummy text.

How to build a Settings Page in WordPress.


To build a WordPress settings page, you can follow these steps:

  1. Create a new plugin or add a new file to an existing plugin.
  2. Add a menu page using the add_menu_page function. This function allows you to add a top-level menu page to the WordPress admin panel.
  3. Use the add_settings_section and add_settings_field functions to create form fields for your plugin’s settings.
  4. Register your plugin’s settings using the register_setting function.
  5. Use the settings_fields and do_settings_sections functions to output your form fields in the correct format.
  6. Add a submit button to your form using the submit_button function.
  7. Save any changes to the plugin’s settings by handling the form submission using the update_option function.

Example for Single Text Field

Here is an example of a basic plugin that adds a menu page and displays a form with a single text field:


// Add a top-level menu page
    'My Plugin Settings',
    'My Plugin',

// Callback function for the plugin's settings page
function my_plugin_settings_page() {
    <div class="wrap">
        <h1><?php echo esc_html( get_admin_page_title() ); ?></h1>
        <form action="options.php" method="post">
            // Output nonce, action, and option_page fields for a settings page
            settings_fields( 'my_plugin_options' );
            // Output setting sections and fields
            do_settings_sections( 'my_plugin' );
            // Submit button

// Register a new setting and its sanitization callback

// Add a new settings section
    'My Plugin Settings',

// Add a new field to the settings section
    'My Setting',

// Callback function to render the settings field
function render_my_plugin_field() {
    // Get the current value of the setting
    $setting = get_option( 'my_plugin_setting' );
    <input type="text" name="my_plugin_setting" value="<?php echo esc_attr( $setting ); ?>">

// Sanitization callback for the setting
function sanitize_my_plugin_setting( $value ) {
    return sanitize_text_field( $value );