Home>Support>PageBuilder messes up get_the_excerpt() function

PageBuilder messes up get_the_excerpt() function

Using wordpress 4.4.2 and latest pagebuilder.

I’m developing widgets based on the SO Widgets Bundle framework.
In the widget templates, when I try to use get_the_excerpt(), there is some sort of html code inception (hundred of div with id=”pb-POSTID-NUMBER”) and the request times out.

example code (in a widget template):

$extrait = esc_attr(get_the_excerpt());

That line is enough to play havoc.

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, 7 months ago Alexandre Plennevaux

    I realize you may need to see more code to believe me, here is the full template.

    <?php
    
    $current_post_id = get_the_ID();
    $term = get_term($term_id);
    
    ?>
    <aside class="in-this-taxonomy">
    	<p class="ui-title"><?php echo strtoupper($term->taxonomy) ?>
    
    
    	<h1><a href="<?php echo get_term_link($term) ?>"><?php echo $term->name  ?></a></h1>
    
    <?php if($title_image){
        $img_url= category_image_src( array('size' => 'vignette-standard-carree'  ,'term_id'=>$term_id) , false );
        ?>
        <img src="<?= $img_url?>" alt="<?php echo esc_attr($term->name)  ?>" >
        <?
    }
    
    
    // Process the post selector pseudo query.
    $args = array(
    	'tax_query' => array(
    		array(
    			'taxonomy' => $term->taxonomy,
    			'terms'    => $term_id,
    		),
    	),
    );
    $query = new WP_Query( $args );
    global $post;
    
    if($query->have_posts()) {
    	$total = $query->post_count;
    ?>
    <ol style="counter-reset:taxonomie <?php echo ($total+1) ?>;" class="taxonomy-link-list">
    
    <?php
    	// Loop through the posts and do something with them.
    
    	while($query->have_posts()) : $query->the_post();
    	setup_postdata();
    	$selected = ($current_post_id == get_the_ID()) ? 'class="selected"':'';
    ?>
    	<li <?= $selected ?>><a href="<?php the_permalink(); ?>" title="<?php echo esc_attr( '' ); ?>" class="popup">
    		<?php
    	echo replace_br_by_space(get_the_title());
            // uncomment this breaks the page.
    	//the_excerpt();
    ?>
    		</a></li>
    
    
    	<?php
    
    	endwhile;
    	wp_reset_postdata();
    }
    ?>
    </ol>
    </aside>
    
  2. 8 years, 6 months ago Alex S
    Hi, I Work Here

    Hi Alexandre,

    Thanks for letting us know about this. I’ve logged this as a potential bug in our issue tracker. We’ll investigate this as soon as possible and try to come up with a fix.

  3. 8 years, 6 months ago Alex S
    Hi, I Work Here

    Hi Alexandre,

    Just an update; I’ve tried this locally and unable to replicate. Could you provide more information about the page builder? A layout export with a copy of the widget you’re building would be a huge help for us.

  4. 8 years, 6 months ago Private Message - Alexandre Plennevaux

    This is a private message.

  5. 8 years, 6 months ago Private Message - Alexandre Plennevaux

    This is a private message.

  6. 8 years, 6 months ago Private Message - Alex S Hi, I Work Here

    This is a private message.

  7. 8 years, 6 months ago Alexandre Plennevaux

    here , via dropbox Private Snippet

  8. 8 years, 6 months ago Alex S
    Hi, I Work Here

    Hi Alexandre,

    Thank you for that. I’ll run a couple of tests and get back to you some time over the weekend.

  9. 8 years, 26 days ago dash8x

    I can also confirm the same issue. Caling

    the_excerpt()

    or

    get_the_excerpt()

    for posts using the page builder causes some sort of infinite loop and the request times out.

  10. 7 years, 11 months ago micemade

    Yep, same here … It took me a while to realize it’s not caused by my bad templating … :)

    Any hope for solution ?

  11. 7 years, 11 months ago talbert

    I am having the same problem

  12. 7 years, 9 months ago Volkmar Kantor

    Hi,
    ich have the same issue on “the_excerpt” and if i want to use “$content = apply_filters( ‘the_content’, $content );”.
    For the apply_filters-Problem i found a solution in your forum.

    @core-team: It looks like that you use queried_object on a place you shouldn’t use it.
    Every time i use “apply_filters( ‘the_content’, $content );” it processes the content of the queried-object instead of the content i provide in the filter.

    Would be great if you could fix this – its pretty annoying.

  13. 7 years, 9 months ago Volkmar Kantor

    I investigated the page-builder code a little.
    The problem with “the_excerpt“, “get_the_excerpt” and “apply_filters( ‘the_content’, $content );” is that the global $post variable is used inside “siteorigin_panels_filter_content“.

    The developers have to use it cause, the page-builder-content is not directly stored in the page-content, but in the meta-data of the post.

    If you want to use “the_excerpt“, “get_the_excerpt” or “apply_filters( ‘the_content’, $content );” there are 2 Solutions.
    EXAMPLE

    ...
    //the Problem --> the following line will output the content of the current global $post-object instead of 'my super fancy content'
    echo apply_filters( 'the_content', 'my super fancy content' );
    
    //use of the_excerpt() will always output the excerpt of the global $post object
    the_excerpt();
    ...
    
    ...
    //First Solution --> override the global $post object
    global $post;
    $post = $overrideWithNewPostObject;
    echo apply_filters( 'the_content', 'anyways whats written here' );
    wp_reset_postdata();
    ...
    
    ...
    //Second Solution --> disable the siteorigin filter for a moment (needs PHP7)
    $old_value = apply_filters('siteorigin_panels_filter_content_enabled',true);//remember old settings
    add_filter('siteorigin_panels_filter_content_enabled', function() { return false; });
    $content = apply_filters('the_content', $post->post_content);
    add_filter('siteorigin_panels_filter_content_enabled', function() use ($old_value) { return $old_value; });
    ...
    
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