Add custom input field in settings page in WordPress dashboard

In this short code snippet we will add a custom input box field in the settings page in WordPress dashboard. In this example we are going to add Store Address as a simple text field. With slight modifications you can also change location of this input field from general settings to Writing, Reading Discussions or Media pages under settings menu. For changing it’s location just replace general with any of the following keys.

Writing – writing

Reading – reading

Discussion – discussion

Media – media

//Add input field in the settings page in WP dashboard
add_filter('admin_init', 'rp_register_general_settings_custom_field');
function rp_register_general_settings_custom_field(){
	register_setting('general', 'store_address', 'esc_attr');
	add_settings_field('store_address', '<label for="store_address">'.__('Store Address').'</label>' , 'create_store_address_field_html', 'general');
function create_store_address_field_html(){
	$value = get_option( 'store_address', '' );
	echo '<input type="text" id="store_address" name="store_address" value="' . $value . '" />';
Need a helping hand in fixing your website issues?

If you are facing any problems in implementing these code snippets and tutorials, you can hire us to fix your website issues.

Hire Us