[wp-trac] [WordPress Trac] #18561: Better Way to Insert Things Below Individual Posts

WordPress Trac wp-trac at lists.automattic.com
Thu Sep 1 04:38:24 UTC 2011


#18561: Better Way to Insert Things Below Individual Posts
-------------------------+------------------------------
 Reporter:  jane         |       Owner:
     Type:  enhancement  |      Status:  new
 Priority:  normal       |   Milestone:  Awaiting Review
Component:  General      |     Version:  3.2.1
 Severity:  minor        |  Resolution:
 Keywords:               |
-------------------------+------------------------------

Comment (by johnjamesjacoby):

 The problem isn't hooking into 'the_content' it's executing code after
 everything else.

 What we need is something like :

 {{{
 function the_rest() {
     global $post;

     // Always fires before the rest of a posts extra content
     do_action( 'before_the_rest' );

     // Execute the rest of a posts content
     do_action( 'the_rest', $post );

     // Always fires after the rest of a posts extra content
     do_action( 'after_the_rest' );
 }
 }}}

 With something like this, themes use the_rest(); like they use
 the_content(); but are able to hook whatever they want into it. This lets
 theme authors decide where the rest of a posts additional content should
 go. I'm passing the $post global here for convenience, so plugin and theme
 authors don't even need to declare it themselves; it gets passed as a
 parameter and can be used to make decisions about what to display there in
 what context.

 Even though actions do have priorities, I've added 'before' and 'after'
 actions here too. This is so plugins and themes can play politely with
 each other regardless of their action priority. They obviously aren't
 *needed* but I included them as a reminder that themes with more actions
 allow for more flexibility like this when it's needed.

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


More information about the wp-trac mailing list