BUG: Incorrect excerpt when Excerpt highlighting is enabled #3101
Closed
Description
opened on Nov 1, 2022
Describe the bug
When the Excerpt highlighting
is enabled, we call the get_the_excerpt
function outside of the loop for the different post. It returns the excerpt of the post of main loop. This happened because get_the_content is looking for the content of main loop post.
Steps to Reproduce
- Enable
Excerpt highlighting
option - Create a post and leave the excerpt empty
- Search for that post through the code.
$posts = get_posts( [ 's' => 'searchTerm' ] );
var_dump( get_the_excerpt( $post[0] ) );
- Returns the excerpt of different post.
Expected behavior
Should return the excerpt of correct post.
Additional context
Activity