WordPress.org

Ready to get started?Download WordPress

Forums

Save or Fetch Settings as a Group (But not for an options page) (4 posts)

  1. Leo Blanchette
    Member
    Posted 1 year ago #

    I'm not sure I understand this properly, or maybe I'm just not searching it properly.

    How do you save options such as they are part of a family that can be fetched in one query?

    Is it necessary to do this through an options page, or can it also be done programatically?

  2. Well... it depends on how you want to code your options and how you want to retrieve them.

    WP provides a way to 'register' settings so they are easily accessed using a simple line of code such as get_option(). You can either store them separately (not desirable), or as an array (preferred).

    However, if you need more control over your options.. and want to setup your own database tables.. you can use the global $wpdb to prepare and execute your database args and queries.

    Hope this helps...

  3. Leo Blanchette
    Member
    Posted 1 year ago #

    Ok, I've been using update_option() and get_option() for quite some time.

    So really the most practical way would be to pack a bunch of settings into one array and then do an update_option('buncha_stuff', $array); ?

  4. Yup. That's the "cleanest" and most preferred, in my opinion.

    You have to be careful to only update the ones you need.. and not erase the others in the process. You can use a conditional to check if each option has changed before updating.

Topic Closed

This topic has been closed to new replies.

About this Topic