[wp-trac] [WordPress Trac] #30288: set import directory for get_template_part()

WordPress Trac noreply at wordpress.org
Tue Nov 11 01:08:22 UTC 2014


#30288: set import directory for get_template_part()
-----------------------------+-----------------------
 Reporter:  Billy Mathews    |       Owner:
     Type:  feature request  |      Status:  reopened
 Priority:  normal           |   Milestone:
Component:  Themes           |     Version:  trunk
 Severity:  normal           |  Resolution:
 Keywords:  has-patch        |     Focuses:  template
-----------------------------+-----------------------
Changes (by Billy Mathews):

 * keywords:   => has-patch


Comment:

 Here is an initial patch to show the functionality I am talking about.

 I have stepped through and tested this code and it works as expected.
 Using the following code in my functions.php I am able to use template
 parts in a "partials" folder inside my theme directory (as well as in the
 theme's directory itself).


 {{{
 function add_import_dirs($dirs){
     $dirs[] = 'partials';
     return $dirs;
 }
 add_filter('template_part_import_directories', 'add_import_dirs', 10, 1);
 }}}

 Not sure if it may be worth making this a wrapper function?

--
Ticket URL: <https://core.trac.wordpress.org/ticket/30288#comment:6>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list