[wp-trac] [WordPress Trac] #39949: get_the_excerpt() in a widget doesn't work as intended

WordPress Trac noreply at wordpress.org
Thu Feb 23 10:43:59 UTC 2017


#39949: get_the_excerpt() in a widget doesn't work as intended
-------------------------------+-----------------------------
 Reporter:  madhatter2099      |      Owner:
     Type:  defect (bug)       |     Status:  new
 Priority:  normal             |  Milestone:  Awaiting Review
Component:  Posts, Post Types  |    Version:  4.7.2
 Severity:  normal             |   Keywords:
  Focuses:                     |
-------------------------------+-----------------------------
 I'm trying to print out the excerpt for a page in a widget. The excerpt
 isn't explicitly set in the post, but is successfully added on other pages
 (ie on the category page I can use the_excerpt() and one will be created.

 Inside a widget I'm trying to use
 {{{
 get_the_excerpt($post)
 }}}
 where $post is a WP_Post object. Instead of returning the excerpt for the
 given post the function returns the excerpt for the current post.

 I then tried using the apply_filters() function as follows:
 {{{
 apply_filters('get_the_excerpt', get_post_field('post_excerpt', $post))
 }}}

 and was met with the same problem. I also tried passing in the post ID
 instead of the object but get the same incorrect excerpt. I don't think
 this is what should be happening, I expect to get back an excerpt from the
 given post, not the current page's excerpt.

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


More information about the wp-trac mailing list