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.

PageBuilder messes up get_the_excerpt() function

10 years ago · Last reply by Volkmar Kantor 9 years ago

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.

Need fast email support? Get SiteOrigin Premium

Replies

13
  1. Alexandre Plennevaux 10 years, 6 days ago

    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. Alex S Staff 10 years, 5 days ago

    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. Alex S Staff 10 years, 5 days ago

    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. Alexandre Plennevaux Private 10 years, 5 days ago

    This is a private message.

  5. Alexandre Plennevaux Private 10 years, 5 days ago

    This is a private message.

  6. Alex S Private Staff 10 years, 5 days ago

    This is a private message.

  7. Alexandre Plennevaux 10 years, 5 days ago

    here , via dropbox Private Snippet

  8. Alex S Staff 10 years, 5 days ago

    Hi Alexandre,

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

  9. dash8x 9 years, 6 months ago

    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. micemade 9 years, 5 months ago

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

    Any hope for solution ?

  11. talbert 9 years, 4 months ago

    I am having the same problem

  12. Volkmar Kantor 9 years, 2 months ago

    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. Volkmar Kantor 9 years, 2 months ago

    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.

Have a different question or issue?

Start New Thread