WP Discourse error message: longer than 32000 characters

Hey there
@Simon_Cossar Maybe you know this one

I tried to update this post to the linked discourse topic, but I get the error message that it exceeded 32000 character, which is not the case. publishing the post to discourse worked without any issues

FIY I use the following functions.php entries:

// show wp posts embedded in discourse via iframe
// https://meta.discourse.org/t/wp-discourse-how-to-deal-with-shortcodes-in-post/58838/5
add_filter( 'discourse_publish_format_html', 'wpdc_custom_discourse_publish_format_html', 10, 2 );
function wpdc_custom_discourse_publish_format_html( $output, $post_id ) {
    $permalink = get_the_permalink( $post_id );
	$content_post = get_post( $post_id );
	$content = $content_post->post_content;
	$content = apply_filters('the_content', $content);
	$content = str_replace(']]>', ']]>', $content);

    <iframe width="690" height="2000" src="<?php echo esc_url( $permalink ); ?>" frameborder="0"></iframe>
	<div data-hide="true"><?php echo $content; ?></div>
    $output = ob_get_clean();

    return $output;


// upwork by njegos vukadin

add_action( "wp_head", "detect_embedding", 1 );
add_action( "wp_head", "modify_embedded_links", 11 );

function detect_embedding()
    function isEmbedded () {
	    try {
	        return window.self !== window.top;
	    } catch (e) {
	        return true;
	if( isEmbedded() ){
		document.documentElement.className = document.documentElement.className + " embedded";
	.embedded body > *:not(#page),
	.embedded #main > *:not(article),
	.embedded #right-sidebar {

	.embedded #main {


function modify_embedded_links(){
		if( isEmbedded() ){
				return this.href.split("#")[0] !== window.location.href.split("#")[0];

The error message is the response that is returned from Discourse when you publish the post. I am surprised that the post was published with the error.

Since you are publishing the entire post as an iframe, Iā€™m not sure why you are adding the post content after the iframe.

1 Like

to make sure the post gets some relevance for the discourse search