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.
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.
You must be logged in to post a comment.
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.
Yes, basically,
get_header()
andget_footer()
loads templates namedheader.php
andfooter.php
.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.
If you look at the source for
get_header()
andget_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:The Sage framework uses this approach for the header and footer, just without the wrapping function. See source.