[theme-reviewers] Rule Addition?

Otto otto at ottodestruct.com
Sat Feb 2 23:38:20 UTC 2013


On Sat, Feb 2, 2013 at 5:15 PM, Bruce Wampler <weavertheme at gmail.com> wrote:
> Given that the templates are supposed to be loaded using get_template_part
> anyway, maybe the functionality belongs there and no one would have to do
> anything.
>
> Bruce Wampler
>

It would be nice if there was a sort of standardized "list" of template parts.

For example, "content" is starting to be standard-ish. Jetpack
specifically uses it in the Infinite-Scroll implementation.

For the definition of it, I'd make it something along these lines:

= Template Part Standard =

Primary name: "content"

Secondary name: post format (from get_post_format)

Description: The content template part is the entirety of the post
output that is inside "the Loop". This would be the main "div" or
other container that gets the post_class() call added to it for the
post classes, as well as everything inside it. Note that by moving
this content into a template part, the context of the executing code
would no longer be global, so commonly used variables like $post and
similar would need to be declared as explicitly global at the
beginning of the template part file for them to accessible.

Example usage: In the Loop.

while (have_posts()) : the_post();
    get_template_part( 'content', get_post_format() );
endwhile;

Uses: The use of the content template part enables the content of a
post to be generated from a separate file as well as by other plugins
or code. So, for example, Jetpack's Infinite Scroll feature is capable
of using the content part to generate the post content individually,
allowing the posts to be sent to the page via javascript requests,
thus enabling the infinite-scroll behavior. This method also allows
for easy customization of the individual look of posts using various
post formats, since content.php can be separated from
content-quote.php or content-aside.php, for example.

-Otto


More information about the theme-reviewers mailing list