2
votes

Are there any potential issues with using get_template_part in place of get_header, get_footer, and get_sidebar.

I'd like to keep my theme folder organized and would be nice to move these pieces to the parts directory.

4

4 Answers

1
votes

Yes, it's perfectly legitimate. As you know, everything but index.php and style.css is optional. Nicely addressed already at https://wordpress.stackexchange.com/questions/16554/when-is-get-template-part-preferable-to-simply-using-the-template-php-files.

0
votes

Yes, basically, get_header() and get_footer() loads templates named header.php and footer.php.

0
votes

They are required functions. You would actually get errors in a dev enviroment if they are not there. Also those functions are heavilly hooked by other functions and plugins.

0
votes

If you look at the source for get_header() and get_footer() you can see there isn't much going on besides calling the hook and loading the include. To preserve the hook and move your header template anywhere you want you could just define a custom get_header() function:

function custom_get_header($path) {
  do_action('get_header');
  get_template_part($path);
}

The Sage framework uses this approach for the header and footer, just without the wrapping function. See source.