#40258 closed enhancement (duplicate)
Add hook for get_template_part
Reported by: | tazotodua | Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | |
Component: | Themes | Keywords: | |
Focuses: | Cc: |
Description (last modified by )
We frequently use themes, which themselves use
get_template_part('smth1/smth2')
however, i many cases, we want (from custom plugin) to avoid inclusion of specific template parts.
there seems no solution, rather than manually modifying themes inner code to avoid getting that particular template part.
It will be better if there was a hook:
function get_template_part( $slug, $name = null ) { ..... $slug =apply_filters('get_template_part_filter', $slug, $name); if(empty($slug)) return; ........ }
Change History (3)
Note: See
TracTickets for help on using
tickets.
Another problem arises when in theme there is:
get_template_part( 'components/footer/site');
as from [https://core.trac.wordpress.org/browser/tags/4.7/src/wp-includes/general-template.php#L158 ):
it becomes:
add_action('get_template_part_components/footer/site'
and I think slash there is not a good idea.