Skip to content

BUG: Incorrect excerpt when Excerpt highlighting is enabled #3101

Closed
@burhandodhy

Description

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

  1. Enable Excerpt highlighting option
  2. Create a post and leave the excerpt empty
  3. Search for that post through the code.
	$posts = get_posts( [ 's' => 'searchTerm' ] );
	var_dump( get_the_excerpt( $post[0] ) );
  1. Returns the excerpt of different post.

Expected behavior

Should return the excerpt of correct post.

Additional context

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions