Opened 6 years ago
Last modified 6 years ago
#43618 new defect (bug)
get_the_excerpt breaking wp-json API
Reported by: | DannyCooper | Owned by: | |
---|---|---|---|
Milestone: | Awaiting Review | Priority: | normal |
Severity: | normal | Version: | 5.0 |
Component: | Posts, Post Types | Keywords: | |
Focuses: | rest-api | Cc: |
Description
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
Change History (2)
Note: See
TracTickets for help on using
tickets.