How To Have Two Gutenberg Editors On One Post?

You could add some kind of separator (a separator block?) in Gutenberg, then filter the_content() to check for the separator to display each half, by setting a switch on the first half and detecting it for the second:

add_filter('the_content', 'content_splitter');
function content_splitter($content) {
    $separator = "<!-- wp:core/separator";
    $pos = strpos($content, $separator);
    if ($pos !== false) {
        global $split_content;
        if (!isset($split_content) && $split_content) {
            $content = substr($content, 0, $pos);
            $split_content = true;
        } else {
            $part_b = substr($content, $pos, strlen($content));
            $pos = strpos($part_b, " -->") + 4;
            $content = substr($part_b, $pos, strlen($part_b));
        }
    }
    return $content;
}

So the first content position would display everything before the separator and then you could call the_content() again in the second (full width) position and it would display everything after the separator.

Obviously with this method you would need to ensure there is only one separator block in the content, and if you have separator blocks in other content it would cut off the second half, so you might need to add extra conditions to prevent that (detect post type or page?)

That said any other block type could be used for a similar purpose by changing the separator string in the code . (Note: I haven’t tested this code or the particular separator string <!-- wp:core/separator, this is simply a code example.)

Leave a Comment