[wp-trac] [WordPress Trac] #12976: Add get_post_content()/get_post_excerpt() and save_postdata()/restore_postdata() for support.

WordPress Trac wp-trac at lists.automattic.com
Thu Apr 15 04:04:55 UTC 2010


#12976: Add get_post_content()/get_post_excerpt() and
save_postdata()/restore_postdata() for support.
--------------------------+-------------------------------------------------
 Reporter:  mikeschinkel  |       Owner:            
     Type:  enhancement   |      Status:  new       
 Priority:  normal        |   Milestone:  Unassigned
Component:  Post Types    |     Version:  3.0       
 Severity:  normal        |    Keywords:            
--------------------------+-------------------------------------------------
Changes (by mikeschinkel):

 * cc: mikeschinkel@… (added)


Comment:

 Replying to [comment:1 nacin]:
 > get_the_title() already takes a post ID, as does a few others. I'm
 pretty sure there is a ticket or two that suggest doing the same for
 get_the_content() and others.
 >
 > We could probably do it so get_the_content() will not rely on the
 globals if you requested with a specific post in mind. Then again, it also
 does a lot of crazy things, such as paging, <!--more-->, and password
 protection.

 I'm probably being a bit too idealistic here in hoping for consistency but
 one of the difficulties I have in using most of the get_*() and the_*()
 functions is how inconsistent the parameter sets are. It's reminds me of
 PHP itself. :)

 What I'm hoping for (longer term) is a set of functions with consistent
 parameters and argument keys across the set of functions, i.e.:
 {{{
 $foo = get_post_*($post,$args);
 the_post_*($post,$args);
 }}}
 Note I'm envisioning these as functions for programmers more than as
 "template tags" for end users.

 Replying to [comment:2 filosofo]:
 > What we need is something that you can pass an object ID to and return
 the excerpt or content, filtered. We don't need all those global
 dependencies, which are vestiges of the bad old days.

 +1

 My patch was but one way to attempt to skin that cat.  I chose to write
 new functions as opposed to modifying existing functions but a better
 approach might be to refactor the existing ones into more reusable units.
 Not knowing the core dev's preference I didn't attempt a refactor. Either
 way, a workable solution would be grand.

-- 
Ticket URL: <http://core.trac.wordpress.org/ticket/12976#comment:3>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list