Add a new option in general setting wordpress php

To add a new option in the General Settings page of a WordPress website, you'll need to create a new option in the wp_options table and then add a field to the options-general.php file.

Here are the steps:

Step 1: Create a new option in the wp_options table

You can use the following SQL query to create a new option in the wp_options table:

INSERT INTO wp_options (option_name, option_value, autoload) VALUES ('new_option_name', 'default_value', 'no');

Replace new_option_name with the name of the new option you want to add, and default_value with the default value you want to set for the option.

Step 2: Add a field to the options-general.php file

In the options-general.php file, you'll need to add a new field to the general_settings array. This file is located in the wp-admin directory of your WordPress installation.

Open the options-general.php file in a code editor and add the following code:

<?php
//...

$general_settings = array(
    //...
    'new_option_name' => array(
        'label' => 'New Option Label',
        'type' => 'text',
        'description' => 'New Option Description',
    ),
    //...
);

Replace New Option Label with the label you want to display for the new option, text with the type of input field you want to use (e.g. text, checkbox, dropdown), and New Option Description with a brief description of the option.

Step 3: Save the changes

Save the changes to the options-general.php file and refresh the General Settings page in your WordPress dashboard.

Step 4: Update the option value

To update the value of the new option, you can use the update_option function in your theme's functions.php file or in a plugin.

For example:

update_option('new_option_name', 'new_value');

Replace new_value with the new value you want to set for the option.

That's it! You should now see the new option in the General Settings page of your WordPress dashboard.