I am trying to export the plugin options that I created.

if(!get_option('myplugin_opts') ){

and also I want to know how I could import the options to WordPress for my plugin, thanks

  • 1
    is there any information about what your plugin options are? Or what you mean by import/export? Are you trying to build an import/export page in your plugin? Or are you trying to copy the options from one site to another? Or build a CLI command? Any context you can add would be super helpful
    – Tom J Nowell
    May 23 at 22:03
  • You could export them using either get_option($name) on all your keys, or extracting them from wp_load_alloptions() array if they're autoloaded options (default). Make a JSON file or just string and download it, read it later and use set_option($name, $value) to import each option individually.
    – Ismail
    May 24 at 2:57
  • @TomJNowell yes i'm trying to build export and import page in my plugin, so people who gonna use my plugin will copy the options from one site to another if they do backup May 24 at 9:36
  • do you know how to create empty/blank menus and pages in WP Admin? If we can narrow it down to the specific part that isn't clear to you it will help when writing the answer
    – Tom J Nowell
    May 24 at 10:06


Your Answer

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

Browse other questions tagged or ask your own question.