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

WordPress Trac wp-trac at lists.automattic.com
Fri Sep 2 16:43:30 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 aaroncampbell):

 Ok, I put up two patches:

 [attachment:18561.diff] adds the_rest which was JJJ's idea.  I simplified
 his original idea by removing the before_the_rest and after_the_rest
 actions because you can just add a low or high priority to your action to
 accomplish the same thing.

 [attachment:18561.twentyeleven.diff] adds the_rest support to TwentyEleven
 by having it use `the_rest()` as well as having it announce that it does
 with `add_theme_support`.  Hopefully one of the theme guys can add any
 styling that is needed for properly positioning it, but it will put this
 content BELOW the "This entry was posted in..." line.

 I tested it with a plugin of mine that adds related posts by appending to
 the_content.  This is the basic code that a plugin would use:

 {{{
 function how_to_insert() {
         if ( current_theme_supports( 'the-rest' ) )
                 add_action( 'the_rest', 'show_via_the_rest' );
         else
                 add_filter( 'the_content', 'filter_post_content' );
 }
 add_action( 'after_setup_theme', 'how_to_insert', 99 );

 function show_via_the_rest( $post ) {
         echo get_related_posts( $post );
 }

 function filter_post_content($content) {
         $content .= get_related_posts();
         return $content;
 }

 }}}

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


More information about the wp-trac mailing list