How to Create Export/Import Functionality for Plugin

I am following the tutorial here http://wp.tutsplus.com/tutorials/creative-coding/creating-a-simple-backuprestore-settings-feature/

The script shows how to export all options into JSON. Since my plugin creates a custom post type, I would also like to export and import all posts of this custom post type. How can I do that?

Related posts

Leave a Reply

1 comment

  1. There are two basic approaches you can take.

    1. Use the standard wordpress inport / export plugin manually through the admin. Your custom post type must have the property can_export = true (default = true) If you go this route, there are interesting options for adding extra functionality for users, Check out this tutorial on adding export filters specific to a custom post type
    2. Use a custom export / import method you script yourself. For an example of how this might be done, see the Export to Text plugin. Just download it and read the code. For the import side, you would then examine their suggested import plugin, CSV Importer