Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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.

share|improve this question
2  
hmmm duplicate account? Those can be merged! wordpress.stackexchange.com/users/25941/kyle-adams –  Tom J Nowell Feb 19 '13 at 17:44
    
I was about to note the same thing that @TomJNowell noticed. –  s_ha_dum Feb 19 '13 at 17:48

5 Answers 5

up vote 1 down vote accepted

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 a footer.php file in your currently active WordPress theme, you would just need to create an index.php file in your currently active WordPress theme. As long as you have the basic index.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.

share|improve this answer
1  
Note: in the template, look for wp_head() and wp_footer(), which are used to fire the do_action( 'wp_head' ) and do_action( 'wp_footer' ) actions (the actions into which script/stylesheet enqueues are hooked), respectively. –  Chip Bennett Feb 19 '13 at 18:10

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:

  • an index.php with a main loop
  • a style.css with a comment at the top detailing the theme name

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.

share|improve this answer
    
I went ahead and wrote my own header and footer functions so that if youdont want, you don't have to have a header and footer.php –  TheWebs Feb 19 '13 at 17:51
    
hmmm it appears your question and what you're asked are not the same... –  Tom J Nowell Feb 19 '13 at 21:47

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.

share|improve this answer
    
no they are not. –  TheWebs Feb 19 '13 at 17:52

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 no header.php file... Yeah, you guessed right,... it always has an index.php file. :)

beside for all i know, you may be referring to child theme :( which only needs styles.css in its basic form.

share|improve this answer

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

<?php

/**
* Call footer elements.
*/
function thesis_footer_area() {
thesis_hook_before_footer();
thesis_footer();
thesis_hook_after_footer();
}

/**
* Display primary footer content.
*/
function thesis_footer() {
echo "\t<div id=\"footer\">\n";
thesis_hook_footer();
thesis_admin_link();
wp_footer();
echo "\t</div>\n";
}

Thesis header.php

<?php

function thesis_header_area() {
thesis_hook_before_header();
thesis_header();
thesis_hook_after_header();
}

function thesis_header() {
echo "\t<div id=\"header\">\n";
thesis_hook_header();
echo "\t</div>\n";
}

function thesis_default_header() {
thesis_hook_before_title();
thesis_title_and_tagline();
thesis_hook_after_title();
}

Here's an example of how to add a custom function for footer attribution to Thesis using the thesis_hook_before_footer hook

add_action('thesis_hook_before_footer', 'add_custom_attribution'); // Custom footer attribution

function add_custom_attribution () { ?>


    <p>&copy; 2007 - <?php echo date("Y"); ?> All Rights Reserved</p>
    <p>Site design by <a href="http://andrewnorcross.com/" title="Andrew Norcross -  This Is Where The Awesome Happens" target="_blank">Andrew Norcross</a></p>

<?php }

Thesis hooks & filters http://thesishooks.com/thesis-hook-list

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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