• Hi,

    I’m working on migrating a custom CMS to WordPress and giving Gutenburg a spin. So far it’s ok, but I’m having problems with the “Convert To Blocks” and “Transform To” function.

    I have a post imported (via custom logic using wp_insert_post). Within the post there are pre tags containing sourcecode. I would like these to be converted to code blocks when using “Convert To Blocks”.

    I can change what the pre tags are if there is one that is automatically gets converted to code. code does not convert either, pre has better formatting so I used that.

    Failing that, I can use the “Transform to” option, but I can only go from paragraph to preformatted and back. How do I transform a paragraph or preformatted block to a code block? I can add a new block and copy & paste the code, but that isn’t realistic for 600+ pages with upto 8 sourcecode snippets.

    Development version (5.0-RC1-43945).

    Thanks

    • This topic was modified 5 years, 12 months ago by Tim Trott.
    • This topic was modified 5 years, 12 months ago by Tim Trott.
Viewing 1 replies (of 1 total)
  • Thread Starter Tim Trott

    (@azuliadesigns)

    Is there alternatively a way to call “Convert to Blocks” from PHP?

    I want to import 2,400 posts via wp_insert_post, then convert to block as they are inserted, then I will do some string manipulation on the post_content field via SQL (changing preformatted to code), then I can go through individual posts and tidy up one by one.

    Something like wp_convert_to_blocks($postId) would be ideal.

    Thanks

Viewing 1 replies (of 1 total)
  • The topic ‘Transform to code (or other block types)’ is closed to new replies.