Some themes that I have seen such as the (famous) thesis or even a few other not so famous themes have just an index.php
(which has nothing in it), functions.php
(call’s their framework) and a style.css
– and of course the comments.php
.
These themes don’t exactly show you where they are storing their CSS – obviously in the header with the enqueue. But if I do something like enqueue my scripts and then call get_header()
and get_footer()
I get the obvious notices about how not having a header.php
and footer.php
is wrong.
So can some one tell me how themes get away with just index.php
? I have read the template hierarchy and while yes everything faults back to index.php
– how is it that these people are getting way with this stuff?
It should be notes that these types of themes do not have things like: header-custom.php
or things like that.
You just need to make sure that you have all the necessary conditions handled properly. You can read more about the WordPress conditional tags available.
As far as not having a
header.php
and afooter.php
file in your currently active WordPress theme, you would just need to create anindex.php
file in your currently active WordPress theme. As long as you have the basicindex.php
file you should be fine.Some themes will run entirely on hooks. I would suggest reading the WordPress Plugin API, and browse through the available WordPress Action hook references and WordPress Filter hook references. For a thorough listing of all action and filter hooks in WordPress see Adam Brown’s WordPress Hooks Database.
Once you have become familiar with WordPress hooks, you can then inspect your currently active WordPress theme for
do_action()
calls. These are hooks created by the theme developer, which you can use to further manipulate your theme.As for the theme not noting this to it user’s is not up to WordPress, but rather up to the theme developer who created the theme and provided it for public usage. You can try contacting the original theme developer and ask for a list of available hooks used through out the theme, or make a request for the original theme developer to write more documentation about the theme.
footer and header.php are completely unnecessary. Those templates and the get_footer() and get_header() functions are purely aids, helpers, guides.
Of course you could start all your templates with
<html><head>...</head><body>
etc but then if you want to change your template you’d need to modify every single file, so header.php and footer.php were introduced, so that you only needed to enter those once.There are also alternative methods such as scribus theme wrappers that use a wrapper.php.
The only files necessary to get a functioning WordPress theme are:
Everything else is optional. So in reality it’s not that the themes are missing a header.php, it’s that other themes added a header.php they didn’t need.
note: It would be good practice to make use of the header and footer files even though they’re not necessary. Just as single.php page.php or functions.php aren’t necessary, they’re still good things to have.
This might be an obvious question, but are the themes you’re referencing child themes by chance?
My company bases all client projects on a parent theme that sets up common methods and a starting point for the HTML, so in a lot of cases the child theme is just a stylesheet and a couple templates to accommodate custom post types.
header.php
,footer.php
and in my opinion,sidebar.php
are not really nessary files, they are just there to give a cleaner less confusing code content, since you have read the wp template hierachy then there should be no problem in understanding why a theme has noheader.php
file… Yeah, you guessed right,… it always has anindex.php
file. 🙂beside for all i know, you may be referring to child theme 🙁 which only needs
styles.css
in its basic form.Thesis does include both a header.php and footer.php file.
thesis > lib > html contains both these files and others.
Both these files include hooks and filters which enable you to add content and filter the output of existing functions.
Themes like Thesis support customization of different parts of the theme using custom functions which include hooks and filters that enable you to modify the header and footer from your child theme or custom_functions.php file.
Other themes use get_template_part which enables you to copy part of the template to your child theme and modify it there so your changes aren’t lost when the parent theme framework is updated.
Other parent themes require you to copy the template file to your child theme and modify it there.
The use of action hooks and filters is considered by many to be a more efficient way to customize your theme without the need to edit the core parent theme files or copy code from the parent theme to the child theme/custom functions file.
Thesis footer.php
Thesis header.php
Here’s an example of how to add a custom function for footer attribution to Thesis using the thesis_hook_before_footer hook
Thesis hooks & filters http://thesishooks.com/thesis-hook-list