0

I am an experienced PHP developer and I am doing my first WordPress project. For reasons I am not going to go into, I don't want to use header.php, get_header(), sidebar.php, get_sidebar(), footer.php and get_footer().

My question is, are there any downsides to not using that structure? Will I miss out on some free built-in functionality?

2

3 Answers 3

2

If you're creating a theme you intend to distribute, using these functions gives users and other developers an opportunity to override the files with a child theme. It's just a predictable way to separate elements of your theme.

Each of them also trigger an action with the same name, which may be useful to some.

If you have some other template scheme, you can use locate_template to make them work with child themes.

1

You won't lose any functionality. Get_header(), get_sidebar(), and get_footer() are basically shortcuts to include these templates.

You can just include your templates using include or require.

The only downside is that if you have custom templates, in a sub directory, you will have to specify the path of the say, the header.php file. If you use get_header() WordPress will find this file automatically.

UPDATE: I noticed that if you use get_sidebar() in a php loop, WordPress will check to see if it was already called and will not echo the output twice.

1
  • downvoted as it is not a simple include, first it will check if there is a child theme to take into acount and then it will look at the right directory. Commented Jun 29, 2016 at 17:28
0

There are two functions added in the header.php and footer.php files wp_head() and wp_footer(). If you do not use get_header() or get_footer() the two function will not be added into your tempalte files. Lots of plugins and themes use those to functions to add in styles and scripts. All you would need to do is add those functions into your template where needed.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.