[wp-trac] [WordPress Trac] #43618: get_the_excerpt breaking wp-json API

WordPress Trac noreply at wordpress.org
Fri Mar 23 13:35:25 UTC 2018


#43618: get_the_excerpt breaking wp-json API
--------------------------+-----------------------------
 Reporter:  DannyCooper   |      Owner:
     Type:  defect (bug)  |     Status:  new
 Priority:  normal        |  Milestone:  Awaiting Review
Component:  General       |    Version:  trunk
 Severity:  normal        |   Keywords:
  Focuses:  rest-api      |
--------------------------+-----------------------------
 When creating a dynamic block for Gutenberg I added this code to a plugin:

 {{{
 register_block_type( 'my-plugin/latest-post', array(
         'render_callback' => 'my_plugin_render_block_latest_posts',
 ) );

 function my_plugin_render_block_latest_posts( $atts ) {

         $output = '';

         $args = array(
                 'posts_per_page' => 3,
         );

         $query = new WP_Query( $args );

         if ( $query->have_posts() ) :
                 while ( $query->have_posts() ) :
                         $query->the_post();
                         $output .= '<li>';
                         $output .= get_the_excerpt();
                         $output .= '</li>';
                 endwhile;
                 wp_reset_postdata();
         else :
                 $output .= 'No posts found.';
         endif;

         return $output;
 }
 }}}

 For some reason, get_the_excerpt is causing this error in /wp-
 json/wp/v2/posts:

 Fatal error: Maximum function nesting level of '256' reached, aborting! in
 /app/public/wp-includes/plugin.php on line <i>899</i>

 When I remove get_the_excerpt() or replace it with get_the_content() the
 error disappears.

 I use 'Local by Flywheel' and this is happening on PHP5.6 and 7

--
Ticket URL: <https://core.trac.wordpress.org/ticket/43618>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list