WordPress.org

Ready to get started?Download WordPress

Forums

Database 'wp-options' table (2 posts)

  1. Hi, I'm working on an option for my plugin which allows a user to import/export the settings from the plugin.

    All settings are stored in the wp-options table; and they are all prefixed with a unique set of characters.

    I'm not very savvy with the database interface, but I have seen other plugins perform similar functions.

    1. Is it possible to isolate my plugin options stored in this table; since they are all prefixed with jwl_?
    2. Can I echo these values to a text box, or write to an xml (or similar) file, which can then be used to import the settings?
    3. Could someone suggest the best place to start?

    I know I'll have to create a form to assist with the import/export. But what is the best way to pull the values? Is get_option my only option?

    Any other information will be most appreciated.

  2. vtxyzzy
    Member
    Posted 2 years ago #

    You can get the options with a standard WP get_results:

    $options = $wpdb->get_results("SELECT * FROM $wpdb->options WHERE option_name LIKE 'jwl\_%'");

    Note the backslash used to escape the underscore.

    This returns an array of objects with the columns of the wp_options table. You should be able to echo these values as you wish.

    EDIT: I 'borrowed' code from the Users To CSV plugin by Joost de Valk to create a plugin to export some data for one of my sites.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.