Sometimes it’s a good idea to have custom options/settings all in one page in admin panel. Those options then can be used anywhere when developing themes or plugins. I.e. those options can be values that are likely to change in future, so that you or someone else wouldn’t have to change it everywhere if it was hardcoded. To create WordPress settings page for custom options is fairly easy, everything can be done in functions.php file in your theme.

Create PHP Class For Settings Page

For better maintainability of our code, let’s create a PHP class in separate file called CustomSettingsPage.php in theme folder.

The class would look like this:

Let’s instantiate this class in our functions.php file:

Now you can navigate in admin panel Settings->Custom Settings Page to what we have created.

Basically, these options are saved in wp_options table in database. Here we have created custom_settings group to have custom_setting_1 and custom_setting_2, which are serialized and stored in one record.

When you will want to get those options somewhere else, just use get_option function, like this:


And that’s it! Now you have an easy way to handle custom options so that you or your client would have a flexible way to change those values in future.