Tuesday, June 30, 2015

Organizing the Templates

Now that we have implemented the key template files (outside of commenting), we have introduced a significant amount of repetition; repetition is bad.  A simple fix is to move the common top and bottom of the HTML files into header.php and footer.php and then include them into each file.

header.php
<html>
  <head>
    <title>Barebones</title>
    <?php wp_head() ?>
  </head>
  <body>

footer.php
<?php wp_footer() ?>
  </body>
</html>    

And then into each of the other files we add the following to the top (replacing the header.php content):

<?php get_header(); ?>

and the following to the bottom (replacing the footer.php content):

<?php get_footer(); ?>

No comments:

Post a Comment