• Resolved tsalagi

    (@tsalagi)


    Hello. I’m currently learning how to create my own templates. There is a question that keeps haunting me everytime I dig into a new template that I hope someone can answer. It’s probably simple. Why in the world are divs opened in the header and closed in the page content? I understand having one main content wrapper div opened in the header and closed in the page but to have two divs opened at the end of the header.php just seems silly to me. Please clarify. I won’t include the entire header but the tail end of the code. Here is the code I have seen many many times.

    <body>
    
    <div id="wrap">
    
    <div id="head">
    	<h1><?php bloginfo('name'); ?></h1>
    	<h3><?php bloginfo('description'); ?></h3>
    </div>
    <!--Retrieving a list of pages from the database is also very easy. We use the wp_list_pages(); function. Note that we also include a title_li= arguement.
    This is to stop the function from creating an extra list item called 'Navigation:' before listing the pages.
    We've also opened the relevant div's and wrappers for the next section.-->
    <div id="nav">
    	<ul>
    	<?php wp_list_pages("title_li="); ?>
    	</ul>
    </div>
    
    <div id="content">
    <div class="contentwrap">
Viewing 2 replies - 1 through 2 (of 2 total)
  • The trick is to code as less as possible redundant code.

    The header.php is called on each and every post/page, and it makes sense to put code you require on all those pages (like page.php, single.php, index.php, category.php, etc) in the header.php.

    I for one would close the div I opened in header.php in the footer.php, btw.

    Peter

    Thread Starter tsalagi

    (@tsalagi)

    Very efficient! Thanks for the ah ha moment of the day! Maybe you give me another? I have a lot of time on my hands this winter. I have 8 hours /day set aside for learning PHP, Mysql, javascript and the WordPress framwork. I’m a quick learner. Approximately how long should it take me to have a full understanding of WordPress themeing and start marketing myself? I know it’s a relative question but I’m trying to set realistic goals.

    Thanks

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Why split divs between header and page’ is closed to new replies.