Adding custom settings per blog

How do I go about adding a custom setting in the settings section for a particular blog / site i.e. going to a the admin page like “/wp-admin/network/site-settings.php?id=6” there are many settings listed. I want to add my own custom setting (just some text) for a particular site. I assume I can do this by manually adding an entry to a database table. Which database table must I add this entry to and once added what php code can I use to access this setting?

Thank you.


  • BlueSea
    • WPMU DEV Initiate

    Thanks for the reply.

    Okay – is there a plugin you can recommend for this purpose (to add a custom setting for each site) i.e. in effect some custom text to be displayed within each site using the get_site_option function?



  • BlueSea
    • WPMU DEV Initiate

    Thanks for the suggestion Phil. That’s not really what I am looking for. I would like a generic way to add my own “settings” to my sites in the network. For example I may want to store a simple custom variable such as the tax rate applicable to that site to be displayed at various places on the site or a piece of text such as: This site is based in “California” where “California” is the variable that varies depending on the site. I think of these variables as site wide attributes that I can display in custom templates or elsewhere on the site as I choose (as I see many plugins do).

    Although you recommended against (warning noted), unless you have a a better suggestion, I think I am going to add these variables directly in the DB to the wp_xxx_options tables (where xxx is the blog Id). To display the relevant variable, I will then extract it using the get_site_option() function as you suggested.

    I think this would be the cleanest way. I also prefer not to add plugins where I can avoid it as I think this can add unnecessary bloat to the site.

    Please let me know if any one strongly disagrees with this approach?


  • BlueSea
    • WPMU DEV Initiate

    Some feedback. I got this working without any negative repercussions as far as I can tell.

    I manually added an entry into the DB as follows:

    wp_xx_options (blog_id, option_name, option_value, autoload)
    VALUES (0, "custom_state", "California", "yes")

    where xx is the blog id (note that the actually blog_id field in the table entry is always zero)

    This “variable” is then displayed in a template as follows:

    <?php echo get_option('custom_state'); ?>

    Note that the function get_option and not get_site_option is used in this case as it is being set on a per blog basis and not site (or rather network) wide.

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.