Support » Developing with WordPress » need to edit wp_options

  • andy3000


    There are some options for the theme appearance that I can’t overide with css.
    These options live in wp_options. They seem not to have any front end (I’m guessing placed there by a plugin that has since been remoed or by a php form). Whenever I try to edit that entry in the database (it is a large array) all the theme customizations revert to a default look. This happens even when I de-activate the theme first.

Viewing 6 replies - 1 through 6 (of 6 total)
  • Aboelabbas


    You can use get_option() to get the value of the option that you want to edit, and
    update_option() to change the value.



    Thanks, the option is stored in an array as s:1544:”products etc (long list of css changes). so I would just add:


    update_option(s:1544,’new css’);
    to the theme’s functions.php?
    or do I have to enter everything in that array?



    It seems that his array contains all options of the theme, so you will need to get this array then change the css item only then update the array in the database.

    But I think the theme should provide you the ability to edit its options through the database even the css. Also you should find a custom built function in the theme that enables you to update a certain single item of this array of options.

    Moderator Jose Castaneda



    This happens even when I de-activate the theme first.

    This just sounds frustrating. What theme is it and where did you get it from? As for the CSS you would use the key not the value so it would be something like:

    // get the options.
    $options = get_option( 'theme_options' );
    // change the option of just the CSS 
    $options['custom_css_value'] = ".neat-class { this:that; }";
    // update the option
    update_option( 'theme_options', $options );

    This is the rough idea of how it would handled 🙂

    Hope that helps a little.



    Abbolebbass was correct . I went through the options one more time and found a text field that had been collapsed.
    What I can’t understand is when I attempted to modify that line in the db it blew all the customizations out and would only allow me to repaste the text I just removed (no changes). If it was protected you’d think it would have just not allowed a change at all.

    Moderator bcworkz


    DB fields are never protected themselves. Code used to access the DB may invoke protections, but if you are directly manipulating the DB with something like phpMyAdmin there are no protections. So much so that I suggest people fully backup their DB before attempting any change through phpMyAdmin.

    I’m assuming you are doing this because you talk about meta keys like “s:1544” and your attempt at changing something blew out the entire thing. It sounds like you are dealing with a serialized array. When we get or save arrays through WP functions like get_option(), the serializing and unserializing is managed automatically. We do not need to be concerned about it.

    When directly altering DB records, serialization is a big concern. Serialized arrays are very structured. If you violate this structure in the slightest way, the entire thing is invalidated. If you fully understand this structure, you can successfully make minor adjustments, but the process is tedious and error prone. I advise against it. Make your changes they way Jose suggests.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘need to edit wp_options’ is closed to new replies.