Add social media custom fields to the general settings page

Use the below code


add_action('admin_init', 'my_general_section');  
function my_general_section() {  
        'my_settings_section', // Section ID 
        'Social Media', // Section Title
        'my_section_options_callback', // Callback
        'general' // What Page?  This makes the section show up on the General Settings Page

    add_settings_field( // Option 1
        'facebook', // Option ID
        'Facebook', // Label
        'my_textbox_callback', // !important - This is where the args go!
        'general', // Page it will be displayed (General Settings)
        'my_settings_section', // Name of our section
        array( // The $args
            'facebook' // Should match Option ID

    register_setting('general','facebook', 'esc_attr'); 

function my_section_options_callback() { // Section Callback
    echo '<p>Social Media</p>';  

function my_textbox_callback($args) {  // Textbox Callback
    $option = get_option($args[0]);
    echo '<input type="text" id="'. $args[0] .'" name="'. $args[0] .'" value="' . $option . '" />';

Use below code for print the field 

<?php print get_option( 'facebook' ); ?>

Related Post

Latest Post

Recent Posts Widget

Make sure to never miss a thing...

Get the latest news from the creative industry along with other creative goodies, conveniently delivered to social media.