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

WordPress Trac wp-trac at lists.automattic.com
Thu Sep 1 22:01:23 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 azaozz):

 I'd imagine it working like this:
 {{{
 add_action( 'the_post', 'my_func', 10, 2 );

 function my_func($next_post, $previous_post) {

   if ( $previous_post ) { // will be null for the 1st post in the loop
     // do something after the post content
   }

   if ( $next_post ) {
     // do something before the next post content
   }
 }
 }}}

 For the last post it would need to hook into 'loop_end':
 {{{
 add_action( 'loop_end', 'my_end' );

 function my_end() {
   global $post;

   my_func(null, $post);
 }
 }}}


 Perhaps that's a bit complicated. We still can make two new actions that
 are fired like the above functions.

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


More information about the wp-trac mailing list