[wp-trac] [WordPress Trac] #18561: Better Way to Insert Things Below Individual Posts
WordPress Trac
wp-trac at lists.automattic.com
Thu Sep 1 15:13:07 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 mattwiebe):
There's no way we can kludge this into the currently existing theme
infrastructure. Here's a thought for a new loop syntax that would be less
radical than the Loop Standard, but easy to implement for themers:
{{{ the_loop(); }}}
Which wraps a standard WP loop in some extra goodness, including actions.
{{{
function the_loop( $slug = 'loop', $name = null ) {
global $post;
do_action( 'wp_before_loop' );
while ( have_posts() ) : the_post();
do_action( 'wp_before_loop_contents', $post );
get_template_part( $slug, $name );
do_action( 'wp_after_loop_contents', $post );
endwhile;
do_action( 'wp_after_loop' );
}
}}}
This accomplishes the goals of having multiple hook'ed places to park
extra content in loop contexts, as well as taking the loop itself into a
separate file, loop.php by default. As you can see, {{{the_loop();}}}
accepts the same args as {{{get_template_part();}}}, so we can use
whichever loop file makes most sense in our context if we're into
specificity and overrides. It does not accomplish the goal of working
without retrofitting, but I think that's not possible with our current
API.
What I like about this API is it's simultaneously easier for themers (no
PHP looping syntax in theme files) and more powerful for plugin
developers.
We then would do something like {{{add_theme_support( 'loop' );}}} to
signal to plugin developers that they should use the new hooks rather than
{{{the_content}}} filter.
Note: obviously this would be an aliased method in {{{WP_Query}}}, just
like {{{have_posts()}}} and {{{the_post()}}}, but this was easier to post
here.
--
Ticket URL: <http://core.trac.wordpress.org/ticket/18561#comment:36>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software
More information about the wp-trac
mailing list