• Resolved dstmalo

    (@dstmalo)


    Hello. I hope this communique’ finds you in the best of health and spirits.

    I intend to create new posts via the WordPress REST API. I have thoroughly reviewed the API documentation here.

    I would like the ability to create Custom HTML blocks via the API. For example, consider this page. The map is an iframe that points to an HTML file residing in a publicly available directory. The entirety of the Custom HTML code is:

    <div class="container">
    <iframe src="https://bwsb.synology.me/wordpress/files/med_map.html" width="50%" height="400" frameborder="0" allowfullscreen="" class="map"></iframe>
    </div>

    How can I create the equivalent of this Custom HTML block via the API?

    I’m flexible about where the Custom HTML block appears in relation to the post content. If it would be easier, the code could appear as a comment beneath the main post.

    Thank you for reading my inquiry.

    • This topic was modified 1 month ago by James Huff. Reason: redundant link removed

    The page I need help with: [log in to see the link]

Viewing 3 replies - 1 through 3 (of 3 total)
  • threadi

    (@threadi)

    You would have to surround the code you pass with block editor markers so that the editor recognizes it as an HTML code block. Example:

    <!-- wp:html -->
    <div class="container">
    <iframe src="https://bwsb.synology.me/wordpress/files/med_map.html" width="50%" height="400" frameborder="0" allowfullscreen="" class="map"></iframe>
    </div>
    <!-- /wp:html -->
    Thread Starter dstmalo

    (@dstmalo)

    This solved my problem. Thank you.

    I notice that the

    <!-- wp:html -->

    tag “escapes” the rest of the message. Are there other escape sequences like this? Is there are list of wp:xxxx tags somewhere?

    The comments are named as the blocks are called internally. Take a look at the list of blocks in the core, where you will also find their names: https://developer.wordpress.org/block-editor/reference-guides/core-blocks/ – Plugins can add further blocks whose names you have to look up there.

Viewing 3 replies - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.