• Resolved Sarwar Alam

    (@alamsarwar)


    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)
  • Hello @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 for alternative options to display Web Stories embeds. Please let us know if you have any other questions.

    Plugin Author Pascal Birchler

    (@swissspidy)

    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. But I’d advise against trying that if you’re not familiar with such an approach.

    Thread Starter Sarwar Alam

    (@alamsarwar)

    Thanks @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

    (@swissspidy)

    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.

    @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 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.