[wp-trac] [WordPress Trac] #18561: Better Way to Insert Things Below Individual Posts
WordPress Trac
wp-trac at lists.automattic.com
Thu Sep 1 20:08:17 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 SergeyBiryukov):
Replying to [comment:57 aaroncampbell]:
> Not to mention, themes can call files whatever they want when using
get_template_part, so how would a plugin know WHICH file to hook to?
That same idea of `add_theme_support()` can be applied here too.
Twenty Eleven could use something like:
{{{
add_theme_support( 'template-parts', array( 'content' => 'content' ) );
}}}
Twenty Ten:
{{{
add_theme_support( 'template-parts', array( 'content' => 'loop' ) );
}}}
[attachment:18561.get_template_part_slug.patch] introduces the
`get_template_part_slug()` function to determine the actual template part
slug used by current theme.
A plugin could then use something like:
{{{
if ( $content = get_template_part_slug( 'content' ) ) {
add_action( "get_template_part_{$content}_after", 'some_function'
);
} else {
add_filter( 'the_content', 'legacy_function' );
}
}}}
--
Ticket URL: <http://core.trac.wordpress.org/ticket/18561#comment:65>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software
More information about the wp-trac
mailing list