This thread is over two years old and may be outdated. Please create a new thread if you need help, or email us if you have an active Premium license.

Page Builder conflict with apply_filters the_content

Resolved 5 replies pluginplugin-page-builder
10 years ago · Last reply by Si Forster 9 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.

Need fast email support? Get SiteOrigin Premium

Replies

5
  1. Greg Priday Staff 10 years, 4 months ago

    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. Andrew Misplon Staff 10 years, 4 months ago

    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. dimizu 10 years, 4 months ago

    Thanks for the feedback.

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

  4. Andrew Misplon Staff 10 years, 4 months ago

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

    All the best.

  5. Si Forster 9 years, 11 months ago

    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.

Have a different question or issue?

Start New Thread