Title: Create Web Stories Programmatically
Last modified: February 3, 2023

---

# Create Web Stories Programmatically

 *  Resolved [Sarwar Alam](https://wordpress.org/support/users/alamsarwar/)
 * (@alamsarwar)
 * [3 years, 4 months ago](https://wordpress.org/support/topic/create-web-stories-programmatically/)
 * Hello, Is there any provision for creating web stories programmatically using“
   wp_insert_post” function? If yes, the how to do I choose/create the template 
   and what are the dependencies I need to take care of? Thanks in advance.

Viewing 5 replies - 1 through 5 (of 5 total)

 *  [Luckyna San](https://wordpress.org/support/users/luckynasan/)
 * (@luckynasan)
 * [3 years, 4 months ago](https://wordpress.org/support/topic/create-web-stories-programmatically/#post-16437047)
 * Hello [@alamsarwar](https://wordpress.org/support/users/alamsarwar/) , our Gutenberg
   block does offer the functionality to embed stories that open in a lightbox when
   clicked on. You can check out this developer [documentation](https://github.com/GoogleForCreators/web-stories-wp/blob/main/docs/web-stories-embeds.md)
   for alternative options to display Web Stories embeds. Please let us know if 
   you have any other questions.
 *  Plugin Author [Pascal Birchler](https://wordpress.org/support/users/swissspidy/)
 * (@swissspidy)
 * [3 years, 4 months ago](https://wordpress.org/support/topic/create-web-stories-programmatically/#post-16437393)
 * Right now there is not really a way to create stories programmatically using 
   PHP, because you need two parts: the story data in JSON format and the generated
   AMP story HTML markup. These can be easily created in the browser using JavaScript,
   but not PHP.
 * In theory you can of course create new posts with `wp_insert_post`, nothing prevents
   you from doing that. However, you’d need to assemble at least the story JSON 
   data yourself, perhaps by following our [JSON schema](https://github.com/GoogleForCreators/web-stories-wp/blob/22758bc6b5a371c6c94744f05cff31c17b0a6570/bin/schemas/story.json).
   But I’d advise against trying that if you’re not familiar with such an approach.
 *  Thread Starter [Sarwar Alam](https://wordpress.org/support/users/alamsarwar/)
 * (@alamsarwar)
 * [3 years, 4 months ago](https://wordpress.org/support/topic/create-web-stories-programmatically/#post-16439194)
 * Thanks [@swissspidy](https://wordpress.org/support/users/swissspidy/) for your
   explanation.
 * What if I continue using Web Stories plugin and just save the “web-story” post_content
   with PHP generated AMP story HTML markup in such case does the plugin takes care
   of the JSON story data and other things?
 * If yes, the what are the other things I need to save while using “wp_insert_post”?
 *  Plugin Author [Pascal Birchler](https://wordpress.org/support/users/swissspidy/)
 * (@swissspidy)
 * [3 years, 4 months ago](https://wordpress.org/support/topic/create-web-stories-programmatically/#post-16439437)
 * No, the plugin cannot generate the JSON from your HTML. So if you just insert
   your stories this way you will not be able to edit them in the editor.
 * If you generate the AMP HTML markup for your stories yourself anyway, it might
   be best to create your own plugin for them, since there wouldn‘t be a benefit
   in using this one.
 *  [Luckyna San](https://wordpress.org/support/users/luckynasan/)
 * (@luckynasan)
 * [3 years, 3 months ago](https://wordpress.org/support/topic/create-web-stories-programmatically/#post-16466483)
 * [@alamsarwar](https://wordpress.org/support/users/alamsarwar/) We are going to
   mark your topic as resolved since we haven’t received any further response. Please
   feel free to open a [new support topic](https://wordpress.org/support/plugin/web-stories/#new-post)
   if you experience any other issues. Thank you!

Viewing 5 replies - 1 through 5 (of 5 total)

The topic ‘Create Web Stories Programmatically’ is closed to new replies.

 * ![](https://ps.w.org/web-stories/assets/icon.svg?rev=2386543)
 * [Web Stories](https://wordpress.org/plugins/web-stories/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/web-stories/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/web-stories/)
 * [Active Topics](https://wordpress.org/support/plugin/web-stories/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/web-stories/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/web-stories/reviews/)

 * 5 replies
 * 3 participants
 * Last reply from: [Luckyna San](https://wordpress.org/support/users/luckynasan/)
 * Last activity: [3 years, 3 months ago](https://wordpress.org/support/topic/create-web-stories-programmatically/#post-16466483)
 * Status: resolved