themehookalliance
themehookalliance copied to clipboard
Add Template Part Filters
Any thoughts on adding filters to the arguments of get_template_part() to allow template parts to be selectively overridden? For example:
get_template_part( apply_filters( 'tha_template_part_slug', 'content' ), apply_filters( 'tha_template_part_name', get_post_format() ) );
This should allow child themes (and potentially plugins?) to specify exactly which template parts should be loaded under different circumstances.
I'd recommend you check how bbPress does it. Specifically see bbp_locate_template (http://bbpress.trac.wordpress.org/browser/trunk/includes/core/template-functions.php#L61) and bbp_get_template_stack (http://bbpress.trac.wordpress.org/browser/trunk/includes/core/template-functions.php#L167)
I'm not sure I fully understand exactly what bbPress is doing, so I could easily be wrong. However, it seems that what bbPress is doing overrides template files loaded by WordPress (for example: index.php), not template parts loaded by the get_template_part() function (for example: content-quote.php). Is that correct?