[wp-trac] [WordPress Trac] #15078: Custom Loops in Twenty Ten

WordPress Trac wp-trac at lists.automattic.com
Sat Oct 9 11:17:49 UTC 2010


#15078: Custom Loops in Twenty Ten
------------------------------------+---------------------------------------
 Reporter:  koopersmith             |        Owner:        
     Type:  defect (bug)            |       Status:  closed
 Priority:  normal                  |    Milestone:  3.1   
Component:  Themes                  |      Version:  3.0.1 
 Severity:  normal                  |   Resolution:  fixed 
 Keywords:  has-patch dev-reviewed  |  
------------------------------------+---------------------------------------

Comment(by nacin):

 Replying to [comment:8 demetris]:
 > As I see it, a main/parent theme should never use both args of
 {{{get_template_part}}} to specify its own template parts.
 >
 > First, there is no reason to:  A theme can, equally well, specify any
 file it wants by using only the first argument.
 >
 > Second, there is reason not to:  By doing so, it denies child themes the
 option to do something more specific for a template.  So, it cancels the
 granularity and flexibility that the second arg of {{{get_template_part}}}
 gives us.

 That's not true. The second argument provides additional context. If you
 wanted to override the loop in Twenty Ten, then you can use loop.php. If
 you wanted to override the loop for a specific instance, such as
 category.php, then you can use loop-category.php. Indeed, the loops for
 attachments, pages, and posts are customized from the default loop, and
 thus we use loop-$context.php in the parent theme.

 But the point is, each of these are used exactly once [1], so there's no
 broader picture of overriding the loop of 10 files (loop.php) versus one
 file (loop-$context). If you want to override this, then you can use loop-
 page.php in the child theme. Absolutely no flexibility is lost, yet
 semantics remain the same and are consistent. Personally, I find the setup
 proposed by koopersmith to be ingenius.

 [1] As mentioned earlier, page.php and the page template use the same
 loop, but this can be overridden in code with is_page_template().

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


More information about the wp-trac mailing list