[wp-trac] [WordPress Trac] #37519: Excerpts not retrieved outside loop when raw excerpt is empty

WordPress Trac noreply at wordpress.org
Sat Jul 30 00:20:16 UTC 2016


#37519: Excerpts not retrieved outside loop when raw excerpt is empty
-------------------------------+-----------------------------
 Reporter:  iandunn            |      Owner:
     Type:  defect (bug)       |     Status:  new
 Priority:  normal             |  Milestone:  Awaiting Review
Component:  Posts, Post Types  |    Version:  4.5
 Severity:  normal             |   Keywords:
  Focuses:  template           |
-------------------------------+-----------------------------
 #27246 / r36319 introduced the ability to fetch the excerpt for a post
 when outside the Loop, but it only works if the post has an excerpt
 manually assigned.

 If the raw `post_excerpt` is empty, then a notice is thrown and an empty
 string is returned.

 `Notice: Trying to get property of non-object in src/wp-includes/post-
 template.php on line 298`

 I expected it to automatically generate the an excerpt from the
 `post_content`, like it would inside the Loop.

 The unit test from r36320 only tests the case where an excerpt is manually
 assigned.

 This snippet in an mu-plugin will reproduce it:

 {{{
 add_action( 'init', function() {
         var_dump( get_the_excerpt( get_post( 1 ) ) );
         wp_die();
 } );
 }}}

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


More information about the wp-trac mailing list