Support » Plugin: Gutenberg » columns block messes if used in custom post type

  • Resolved canetwp

    (@canetwp)


    I’m using this code to output a Gutenberg block:

    $the_post = get_post($my_block, ARRAY_A);
    $postContent = wpautop($the_post[‘post_content’]);
    print_r($postContent);

    when this code is used to output a classic editor content it works perfectly, but when outputting a Gutenberg column the HTML code I get is basically wrong:

    
    <p><!-- wp:columns --></p>
    <div class="wp-block-columns has-2-columns"><!-- wp:column --></p>
    <div class="wp-block-column"><!-- wp:paragraph --></p>
    <p>column 1</p>
    <p><!-- /wp:paragraph --></div>
    <p><!-- /wp:column --></p>
    <p><!-- wp:column --></p>
    <div class="wp-block-column"><!-- wp:paragraph --></p>
    <p>column 2</p>
    <p><!-- /wp:paragraph --></div>
    <p><!-- /wp:column --></div>
    <p><!-- /wp:columns --></p>
    

    Am I making something wrong? Is there a different way to get straight to a custom post type content?

    Thank you!

    • This topic was modified 3 years, 6 months ago by Marius L. J.. Reason: Fixed code formatting
Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter canetwp

    (@canetwp)

    To be complete I must say that HTML output is not working even when opening the post type URL, so it shouldn’t be a print_r($postContent); matter, right?

    tnx

    • This reply was modified 3 years, 6 months ago by canetwp.
    Thread Starter canetwp

    (@canetwp)

    Stupid newbie I am, I should have used
    echo get_post_field( ‘post_content’, $my_block, ‘display’ );
    instead!

    🙂

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘columns block messes if used in custom post type’ is closed to new replies.