How to Change Options in WordPress – GUI and Programmatically

Posted on

The operations of WordPress are defined by a huge number of options that are stored in the database. Most of the common front facing ones are placed in easily accessible checkboxes in the “Settings” section of the WordPress administration dashboard. However, there are a large number of other technical and esoteric options that play subtle roles in how WordPress works. In this article, we take a quick look at two ways of updating these values. The first is via the standard Graphical User Interface or GUI. The second is programmatically so that you can change these values dynamically on the fly in your own code.

Each option has a technical name in addition to the description that we commonly see in the settings page. For example, if we go to “Settings->Reading”, we see a checkbox labeled “Search Engine Visibility”:

search engine visibility off

Because this is a test blog of mine, I’ve disabled search indexing. Let’s take this parameter as an example of the options value we want to change and see how we can modify it in different ways.

Changing Values using the GUI

Of course, the option above is already available to users in WordPress via a checkbox. However, there is another way of doing it. It takes the form of a hidden URL in WordPress that cannot be accessed graphically. Go to your web browser address bar and type in the following:


This hidden URL will bring up all the possible options that you can change in WordPress (and some that you cannot!). It’s a complete and comprehensive list. To make the change, you need to know the option’s internal variable name. In our example, that name is “blog_public”. The list is arranged alphabetically, so it’s easy to find the one you want – or you can simply do a search.

options page find variable

Once you find the variable, make the change and click the “Save Changes” button right at the end of the page. Problem solved!

Changing Values Programmatically

Options can also be changed in code. Doing this dynamically can be beneficial for a variety of reasons. Maybe you want to check for a certain condition before performing an action, or you need to toggle something on or off. In any case, WordPress has a function for getting the value of an option, and another for changing it.

Taking our earlier example of the option that controls whether or not the blog is public, here’s a short snippet of code that sets it to “1” or “public” after checking to see if it’s off:

function set_blog_public() {
         if (get_option( 'blog_public' ) == 0 )
                     update_option( 'blog_public', '1' );
add_action( 'init', 'set_blog_public' );


The function “get_option” returns the value of the option within brackets, whereas the “update_option” function changes that value to whatever you want. This code needs to be inserted into your functions.php file before the closing ?> PHP tag. If you don’t know how to add code to WordPress, here’s a handy tutorial.

The key is to know the exact variable name as well as the list of permissible values it can take. You can get a comprehensive list of options from the WordPress documentation here. It also gives you the data type of the expected value of the option which is useful if you want to avoid any unexpected errors.

Leave a Reply

Your email address will not be published. Required fields are marked *