Skip to content

YeloCommerce

Home » Blog » Add custom field in wp general settings

Add custom field in wp general settings

add_filter('admin_init', 'yelocommerce_general_settings_register_field');
 
function yelocommerce_general_settings_register_fields()
{
    register_setting('general', 'yelocommerce_field', 'esc_attr');
    add_settings_field('yelocommerce_field', '<label for="yelocommerce_field">'.__('New Field' , 'yelocommerce_field' ).'</label>' , 'yelocommerce_general_settings_fields_html', 'general');
}
 
function yelocommerce_general_settings_fields_html()
{
    $value = get_option( 'yelocommerce_field', '' );
    echo '<input type="text" id="yelocommerce_field" name="yelocommerce_field" value="' . $value . '" />';
}

Leave a Reply

Your email address will not be published. Required fields are marked *