Home>Support>apply_filter on string returns unexpected result with Page Builder

apply_filter on string returns unexpected result with Page Builder

Hi there,

I need to output a string from a text editor. I always apply the default ‘the_content’ filter to it to render shortcodes etc.:

apply_filters( 'the_content', $mystring );

However, when the Page Builder is activated in the default editor, this always returns the content of that editor, not the rendered string $mystring.

I think this must be a bug, maybe you can tell me how to work around it.


This is our free support forum. Replies can take several days. If you need fast email support, please purchase a SiteOrigin Premium license.

  1. 6 years, 6 months ago Andrew Misplon Hi, I Work Here

    Hi Paddelboot

    Thanks for reaching out. Page Builder outputs via


    so it isn’t a bug. Do you need to use the


    or could you perhaps rather use something like:

    echo wpautop( $mystring );
  2. 6 years, 6 months ago paddelboot

    Hi Andrew,

    Unfortunately I need to apply the the_content filter on it, for parsing shortcodes or media embed URLs etc.

    I don’t think Page Builder should “appropriate” this filter completely. Imagine someone who adds a second WP Editor to a custom post type editor screen. The filters applied to this content would have to be the same as for the main content, right?


  3. 6 years, 6 months ago Greg Priday Hi, I Work Here

    Hi Paddelboot

    You can think of the_content filter being for $post->post_content and the_content() function. Technically there’s no other way for us to take over the_content() function, without using the_content filter. The only other option would be for us to forces themes to add a separate function that we could use, or to store Page Builder content in $post->post_content as shortcodes. This is the approach some other plugins take, but in general, it seems like people are against that approach.

    WordPress should possibly have offered 2 filters. One filter called maybe text_content that filters generic text content, and another one that filters the output of the_content() function.

    It’s open to interpretation, but to me, the_content filter implies that it’s a filter for a single thing – being the post content, which WordPress calls the_content. Just the same as the_excerpt would refer specifically to a post’s excerpt, rather than generic excerpt/summary text and the_title filter would refer to a posts title, rather than generic title strings.

    To create your own filter for your plugin, you could look at default-filters.php and copy out all the filters that are applied to the_content and rename them to something like myplugin_content.

    add_filter( 'myplugin_content', 'wptexturize'                       );
    add_filter( 'myplugin_content', 'convert_smilies'                   );
    add_filter( 'myplugin_content', 'wpautop'                           );
    add_filter( 'myplugin_content', 'shortcode_unautop'                 );
    add_filter( 'myplugin_content', 'prepend_attachment'                );
    add_filter( 'myplugin_content', 'wp_make_content_images_responsive' );

    This would give you far more control over which filter functions are applied.

    I hope that clarifies things, and our thinking on using the_content filter. Answering it as fully as I can, because it is a question that comes up from time to time :)

  4. 6 years, 3 months ago Howdy_McGee

    If you need to use `the_content` filter you should remove the Site Origin content filter ( and re-add it after you’re finished ):

    remove_filter( 'the_content', 'siteorigin_panels_filter_content' );

    Then when you need it, maybe above a loop, you can re-add this filter:

    add_filter( 'the_content', 'siteorigin_panels_filter_content' );
Replies on this thread are closed. Please create a new thread if you have a question, or purchase a SiteOrigin Premium license if you need one-on-one email support.

Get The Most Out of SiteOrigin with SiteOrigin Premium

Find Out More