[wp-trac] [WordPress Trac] #27246: Add function to get the excerpt outside the loop

WordPress Trac noreply at wordpress.org
Fri Jan 15 22:29:04 UTC 2016


#27246: Add function to get the excerpt outside the loop
---------------------------------------------+-------------------------
 Reporter:  Atoon                            |       Owner:  swissspidy
     Type:  enhancement                      |      Status:  closed
 Priority:  normal                           |   Milestone:  4.5
Component:  Posts, Post Types                |     Version:  3.8.1
 Severity:  normal                           |  Resolution:  fixed
 Keywords:  has-patch has-unit-tests commit  |     Focuses:  template
---------------------------------------------+-------------------------

Comment (by swissspidy):

 With similar template tags I meant `get_permalink()`, `get_the_title()`
 and basically any `get_` function. They all allow passing a `$post` while
 their `the_` equivalents display the values for the current post. In theme
 templates, `the_excerpt()` is usually used, whereas `get_the_excerpt(
 $post )` can also be used by plugins — without manually needing to apply
 filters.

 > Isn't it an option to put functions like this in WP_Post? and change the
 theme functions to call the methods in WP_Post. As a plugin developer I
 would love to use WP_Post more and doing something like this would be a
 good step.

 Oh, I think it is. I haven't found an existing ticket for that, but I've
 seen plenty of code examples of custom `Post` decorator classes
 implementing something similar.

--
Ticket URL: <https://core.trac.wordpress.org/ticket/27246#comment:17>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list