Categories: Wordpress Development

Add Text Field Under General Settings in WordPress

In this article, i’ll try to show you the way for adding text field(s) under general settings which may help you to make dynamic control for many necessary option for WordPress site.

To Find the General Settings:

Go to Dashboard-> Settings -> General where you can see Settings Administration Screen and controls for most effective & necessary information like Site Title, Tagline, URL, Admin-email etc.

 

Now, if we want to add more settings control for our site suppose any links, or any message, or data we can make it very easily without plugin. Just need to follow few steps to do this things.

Here i am showing to add ‘copyright message’ in General Settings. So you just need a text field to do this. Please add this below code to your functions.php file:

 

 add_filter('admin_init', 'my_general_settings_register_fields'); 

function my_general_settings_register_fields() { 
register_setting('general', 'copyright_message', 'esc_attr'); 
add_settings_field('copyright_message', '<label for="copyright_message">'.__('Copyright Message' , 'copyright_message' ).'</label>' , 'my_general_copyright_message', 'general'); } 

function my_general_copyright_message() { 
$copyright_message = get_option( 'copyright_message', '' ); 
echo '<input id="copyright_message" style="width: 35%;" type="text" name="copyright_message" value="' . $copyright_message . '" />'; }

Now, you refresh your dashboard and go to Settings -> General page. You can see a text field added in bottom there. You can add your copyright message in there and click “Save changes”. To get this data in front (in footer.php) page there are two ways:

$copyrightMessage=get_settings('copyright_message');
OR
$copyright_message = get_option( 'copyright_message', '' );

Both will work. Just pick any suitable one and print the variable $copyrightMessage in your html.

That’s it. If you need any further clarification please drop a comments.

Thanks.

This post has already been read 7268 times!

Mehedi Hasan

Cool WordPress Developer having much agile experience to develop any kind of WordPress sites & plugins. Also good in troubleshooting, fixing & making any kind of tweaks for WP site.

More Posts

Mehedi Hasan

Cool WordPress Developer having much agile experience to develop any kind of WordPress sites & plugins. Also good in troubleshooting, fixing & making any kind of tweaks for WP site.

Share
Published by
Mehedi Hasan

Recent Posts

WP Share A Friend – A Way to Capture Lead

What is Lead Capture: In general sense lead capture designates a process or way of…

5 years ago

Unlimited Modal POPUPS on MouseClick

Introduction Unlimited Modal POPUPS on MouseClick: Everyone knows about popup during site visits and most…

5 years ago

WordPress Pregnancy Calculator Plugin

Brief about Pregnancy Calculator : This WordPress Pregnancy Calculator plugin allows users to display an…

5 years ago

Interactive Service Plugin with Hover Effects VC

Introduction About this Service Plugin: This Visual Composer Service Plugin works as an addon to…

6 years ago

WP Dynamic Query String

Introduction of Dynamic Query String : This plugin allows user to set dynamic query string…

6 years ago

How to make scroll PDF in iFrame for iPAD Safari

There is an occasional bug for iPhone and iPad even they are designed as well and…

7 years ago