hdshngout
06-21-2006, 09:08 PM
Wordpress Layouts at first seem extremely hard (and in some cases, not worth the effort), but once you get a feel for how the wordpress templates work, it becomes easier and easier.
Preping the Layout
The first thing you want to do is design a layout in plain html coding, or if you are stuck in a layout block, or are too lazy to design a layout (don’t feel bad, I’ve done the same thing), head over to OSWD.org. It’s an open source template site, which contains literally 1000’s of free templates for you to download and use.
The next thing you want to do is divide your layout into 3 main parts…
Your Header
Your Body
Your Menu Bar
& Your Footer
Typically your header contains
<html>
<head>
<link rel="stylesheet" type="text/css" herf="style.css">
<title>Your Page Title</title>
</head>
<body>
Your Header Information
Take that part of your layout’s coding and save it as header.php. We will come back to this part later.
Now for your footer section. Generally the footer contains…
Your Footer Information
© 2006 Whoever (etc)
</body>
</html>
Take the coding and save it as footer.php
Now whats left in the original template, save as index.php. But Wait! We’re not done yet. Inside the coding find the coding that takes up the menu. This differs per layout, So I theres really not an example I can use, but as a reference its usually in a div called menu, sidebar, navigation, or somthing similar. Take that coding and save it as sidebar.php.
Time To Wordpressify
Lets begin with header.php. To begin find
<link rel="stylesheet" type="text/css" herf="style.css">
and replace it with
<link rel="stylesheet" href="<?php bloginfo(’stylesheet_url’); ?>" type="text/css" media="screen" />
This tells wordpress to look in wp-content/themes/YOURTHEME for the stylesheet. Next find
<title>Your Page Title</title>
and replace it with
<title><?php bloginfo(’name’); ?> <?php if ( is_single() ) { ?> » Blog Archive <?php } ?> <?php wp_title(); ?></title>
This coding tells Wordpress to put the title of your blog into the Blue Title Bar at the top of the browser, (and if you are on a page, it will include the page title with a raquo; between the Blog and Page Title.
Between your head tags (<head> & </head>) add the following code
<meta http-equiv="Content-Type" content="<?php bloginfo(’html_type’); ?>; charset=<?php bloginfo(’charset’); ?>" />
<link rel="alternate" type="application/rss+xml" title="<?php bloginfo(’name’); ?> RSS Feed" href="<?php bloginfo(’rss2_url’); ?>" />
<link rel="pingback" href="<?php bloginfo(’pingback_url’); ?>" />
This code simply gives search engines your RSS information.
The final thing to do to your template is to add your Blog Title and Blog Description to your header. This step is optional as some layouts use images with the blogs name. I figured I should include it for those who don’t.
To do this, find your sites Title and put this in its place
<?php bloginfo(’name’); ?>
and for your blog description
<?php bloginfo(’description’); ?>
This tells wordpress to replace those tags with the Title and Description you chose in your Admin Panel.
Now for the actual blogs. Wordpress uses a loop for its blog, which in english means everything that will be displayed for the entrys must be within 2 tags. This ensures that everything inside the tags will be included with every post. Here is the loop
<?php while (have_posts()) : the_post(); ?>
<div class="post" id="post-<?php the_ID(); ?>">
<h2><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>"><?php the_title(); ?></a></h2>
<small><?php the_time(’F jS, Y’) ?> <!– by <?php the_author() ?> –></small>
<div class="entry">
<?php the_content(’Read the rest of this entry »’); ?>
</div>
<p class="postmetadata">Posted in <?php the_category(’, ‘) ?> | <?php edit_post_link(’Edit’, ‘’, ‘ | ‘); ?> <?php comments_popup_link(’No Comments »’, ‘1 Comment »’, ‘% Comments »’); ?></p>
</div>
<?php endwhile; ?>
<div class="navigation">
<div class="alignleft"><?php next_posts_link(’« Previous Entries’) ?></div>
<div class="alignright"><?php previous_posts_link(’Next Entries »’) ?></div>
</div>
<?php else : ?>
<h2 class="center">Not Found</h2>
<p class="center">Sorry, but you are looking for something that isn’t here.</p>
<?php include (TEMPLATEPATH . "/searchform.php"); ?>
<?php endif; ?>
Preping the Layout
The first thing you want to do is design a layout in plain html coding, or if you are stuck in a layout block, or are too lazy to design a layout (don’t feel bad, I’ve done the same thing), head over to OSWD.org. It’s an open source template site, which contains literally 1000’s of free templates for you to download and use.
The next thing you want to do is divide your layout into 3 main parts…
Your Header
Your Body
Your Menu Bar
& Your Footer
Typically your header contains
<html>
<head>
<link rel="stylesheet" type="text/css" herf="style.css">
<title>Your Page Title</title>
</head>
<body>
Your Header Information
Take that part of your layout’s coding and save it as header.php. We will come back to this part later.
Now for your footer section. Generally the footer contains…
Your Footer Information
© 2006 Whoever (etc)
</body>
</html>
Take the coding and save it as footer.php
Now whats left in the original template, save as index.php. But Wait! We’re not done yet. Inside the coding find the coding that takes up the menu. This differs per layout, So I theres really not an example I can use, but as a reference its usually in a div called menu, sidebar, navigation, or somthing similar. Take that coding and save it as sidebar.php.
Time To Wordpressify
Lets begin with header.php. To begin find
<link rel="stylesheet" type="text/css" herf="style.css">
and replace it with
<link rel="stylesheet" href="<?php bloginfo(’stylesheet_url’); ?>" type="text/css" media="screen" />
This tells wordpress to look in wp-content/themes/YOURTHEME for the stylesheet. Next find
<title>Your Page Title</title>
and replace it with
<title><?php bloginfo(’name’); ?> <?php if ( is_single() ) { ?> » Blog Archive <?php } ?> <?php wp_title(); ?></title>
This coding tells Wordpress to put the title of your blog into the Blue Title Bar at the top of the browser, (and if you are on a page, it will include the page title with a raquo; between the Blog and Page Title.
Between your head tags (<head> & </head>) add the following code
<meta http-equiv="Content-Type" content="<?php bloginfo(’html_type’); ?>; charset=<?php bloginfo(’charset’); ?>" />
<link rel="alternate" type="application/rss+xml" title="<?php bloginfo(’name’); ?> RSS Feed" href="<?php bloginfo(’rss2_url’); ?>" />
<link rel="pingback" href="<?php bloginfo(’pingback_url’); ?>" />
This code simply gives search engines your RSS information.
The final thing to do to your template is to add your Blog Title and Blog Description to your header. This step is optional as some layouts use images with the blogs name. I figured I should include it for those who don’t.
To do this, find your sites Title and put this in its place
<?php bloginfo(’name’); ?>
and for your blog description
<?php bloginfo(’description’); ?>
This tells wordpress to replace those tags with the Title and Description you chose in your Admin Panel.
Now for the actual blogs. Wordpress uses a loop for its blog, which in english means everything that will be displayed for the entrys must be within 2 tags. This ensures that everything inside the tags will be included with every post. Here is the loop
<?php while (have_posts()) : the_post(); ?>
<div class="post" id="post-<?php the_ID(); ?>">
<h2><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>"><?php the_title(); ?></a></h2>
<small><?php the_time(’F jS, Y’) ?> <!– by <?php the_author() ?> –></small>
<div class="entry">
<?php the_content(’Read the rest of this entry »’); ?>
</div>
<p class="postmetadata">Posted in <?php the_category(’, ‘) ?> | <?php edit_post_link(’Edit’, ‘’, ‘ | ‘); ?> <?php comments_popup_link(’No Comments »’, ‘1 Comment »’, ‘% Comments »’); ?></p>
</div>
<?php endwhile; ?>
<div class="navigation">
<div class="alignleft"><?php next_posts_link(’« Previous Entries’) ?></div>
<div class="alignright"><?php previous_posts_link(’Next Entries »’) ?></div>
</div>
<?php else : ?>
<h2 class="center">Not Found</h2>
<p class="center">Sorry, but you are looking for something that isn’t here.</p>
<?php include (TEMPLATEPATH . "/searchform.php"); ?>
<?php endif; ?>