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

WordPress Trac wp-trac at lists.automattic.com
Thu Sep 1 16:50:42 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 Otto42):

 Replying to [comment:23 helenyhou]:
 > I actually agree that modifying something that exists would be better,
 but I also don't think that having this attached to the loop/the content
 in terms of placement is very flexible. I can easily imagine a theme
 author wanting to put it in the loop on an archive page but then in a
 sidebar or widget area on a single. Then again, maybe it's completely
 possible to make `get_template_part` have the ability to be just as
 flexible and I'm just not seeing it.

 Yes, you're not seeing it. get_template_part, as used in twentyeleven,
 does exactly what you're talking about.

 {{{
 add_action ( 'get_template_part_content_after', 'demo', 10, 2);
 function demo($slug, $name) {
   if ($name == 'single') {
     // do output for below the post area
   }
 }
 }}}

 Calls to get_template_part('content',...); are used throughout twenty-
 eleven, but with differing second parameters. If there was an after hook
 (like there already is one for the "before" case), then hooking in and
 outputting stuff below the post proper would be easy, and you could be
 specific about what areas in the theme that it's in.

 Theme authors are already starting to use get_template_part, and will be
 using it more in the future. Now is a good time to start pushing for part
 naming standards and to support them well. Doesn't have to be a formal
 standard, enforced by code. Just a list of common part names would work.

 As pointed out above, there is no possible generic solution that will work
 with all themes from all time. Themes will have to support any solution
 you use. Better to introduce a standard using methods theme authors
 already know about than to create something new that they don't understand
 and will use wrong. For the specific example of "the_rest" that JJJ came
 up with, people in this very thread are already starting to use-it-wrong
 from the original idea, and not one line of code has been written.

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


More information about the wp-trac mailing list