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?
Below are the methods you can try. The first solution is probably the best. Try others if the first one doesn’t work. Senior developers aren’t just copying/pasting – they read the methods carefully & apply them wisely to each case.
There are two basic approaches you can take.
- 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
- 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