0

I'm researching what it would take to develop a custom Wordpress plugin. The plugin is a pretty small one. We just need to persist 2 fields of integer information. It's a pretty basic progress bar with current progress (int) and goal (int).

Is there a simple way of storing that amount of information in Wordpress? Is there a simple API for storing things like this in the db? Or, should I just persist by writing to a basic xml or json file on disk?

Thanks for any help.

  • What's the relation of this information, will it be specific to a post or post type, a comment, is there some common type of data this will be associated with, or is this a one off use? – t31os Apr 29 '13 at 20:19
2

The best way would be to use the built-in Options API to add info to the wp_options table.

To add the option: http://codex.wordpress.org/Function_Reference/add_option

To read the option value: http://codex.wordpress.org/Function_Reference/get_option

1

Use the Options API.

add_option(    'option_name', $values );
update_option( 'option_name', $values );
get_option(    'option_name', $default_value );
delete_option( 'option_name' );

You can store non-scalar values here too, an array with two entries for example. Make sure to use a unique name for the option name, prefix everything.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.