Home>Support>Page Builder conflict with apply_filters the_content

Page Builder conflict with apply_filters the_content

By dimizu, 8 years ago. Last reply by Si Forster, 8 years ago.

I would show the contetn of a specific page in the sidebar. I use this code in the sidebar:

$id=123;
$p=get_page($id);
echo apply_filters('the_content', $p->post_content);

This works fine in all pages, where these sidebar appear. But when i use in a page the Page Builder, then the line

echo apply_filters('the_content', $p->post_content);

not show the content of the page with the id=123, but the content of the current page.

The problem is the function apply_filters, because without the filter this works:

echo $p->post_content;

Only this

echo apply_filters('the_content', $p->post_content);

is a problem, and only with Page Builder. The Problem is theme indipendent. I tested with more themes also with Twentyfifteen.

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

  1. 8 years, 11 months ago Greg Priday
    Hi, I Work Here

    Hi Dimizu

    To avoid conflicts with both Page Builder and other plugins that use the_content to filter the post content, you should rather apply any of the specific filters you need to your sidebar content. You can find these in wp-includes/default-filters.php – line 132 to 137 in the current version of WordPress.

    Hopefully that does the trick :)

  2. 8 years, 11 months ago Andrew Misplon
    Hi, I Work Here

    Hi Dimizu

    Here is a similar explanation:

    http://wordpress.stackexchange.com/questions/134582/apply-filtersthe-content-content-alternative

    And here is a quick mockup that might work for you:

    <?php
    $post_id = 8159;
    $queried_post = get_post($post_id);
    $content = $queried_post->post_content;
    $content = apply_filters('wpautop', $content);
    $content = str_replace(']]>', ']]>', $content);
    echo $content;
    ?>
    
  3. 8 years, 11 months ago dimizu

    Thanks for the feedback.

    “wpauto” is exactly the solution that I’ve found in the meantime :-)

  4. 8 years, 11 months ago Andrew Misplon
    Hi, I Work Here

    Super, really glad to hear you’ve made progress.

    All the best.

  5. 8 years, 6 months ago Si Forster

    This helped me resolve a conflict with Woocommerce Tabs Manager too

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