WordPress:Sezione di una pagina di amministrazione

← ritorno

Sdvsbdrvuydvbuiy5g.png
add_action( 'admin_init', 'my_settings_init' );

function my_settings_init() {

    add_settings_section(
        'sample_page_setting_section',
        __( 'Custom settings', 'my-textdomain' ),
        'my_setting_section_callback_function',
        'sample-page'
    );

	add_settings_field(
	   'my_setting_field',
	   __( 'My custom setting field', 'my-textdomain' ),
	   'my_setting_markup',
	   'sample-page',
	   'sample_page_setting_section'
	);

	register_setting( 'sample-page', 'my_custom_settings_options' );
}

function my_setting_section_callback_function() {
    echo '<p>Intro text for our settings section</p>';
}

function my_setting_markup() {
    ?>
    <label for="my_setting_field"><?php _e( 'My Input', 'my-textdomain' ); ?></label>
    <input type="text" id="my_setting_field" name="my_setting_field">
    <?php
}

fonte: https://themes.artbees.net/blog/custom-setting-page-in-wordpress/