Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Template Part Filters #21

Open
alexmansfield opened this issue Aug 30, 2013 · 2 comments
Open

Add Template Part Filters #21

alexmansfield opened this issue Aug 30, 2013 · 2 comments

Comments

@alexmansfield
Copy link

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.

@MZAWeb
Copy link

MZAWeb commented Aug 30, 2013

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)

@alexmansfield
Copy link
Author

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants