ITC298 > Creating & Customizing a WordPress Theme
If you plan on being a professional website designer/developer, you should really consider creating your own theme.
The Template Files
Creating a template file structure for a WordPress site is fairly easy to do. I started off by using my same old template structure that I always go back to when designing and producing a new website. This way, I was able to develop a WordPress template file structure (system) that was a familiar build for me.
See Also: Building an HTML Template from Master Art | Premium Design Works
Since I was also familiar with the Anatomy of a WordPress Theme, I was able to take my basic template and break it into the standard template files to begin creating my own WordPress theme:

All I had to do then was add the correct WordPress functions into the proper places in my template files and check out the HTML it wrote to write a proper CSS file. It was that simple.
The Functions
The files of WordPress define many useful PHP functions. Some of the functions, known as Template Tags, are defined especially for use in WordPress Themes. There are also some functions related to actions and filters (the Plugin API), which are therefore used primarily for developing Plugins. The rest are used to create the core WordPress functionality.
— http://codex.wordpress.org/Function_Reference
Let’s take a look at some of the basic WordPress functions that you will need to incorporate into your template files and see how they work.
One of the most basic WordPress functions that will use is the wp_title function:

header.php
Here I have used the wp_title function in my title tag to display a page’s title in my browser’s title bar.
The wp_title function gets the title that you have written for your page:

It will (secretly) look into the the WordPress application to access the statements of the function:

general-template.php
And Bob’s your uncle, it will display your page’s title in the browser’s title bar:

Another common function that you will be using is the wp_list_pages function:

header.php
The wp_list_pages function displays a list of WordPress Pages as links. It is often used to customize the Sidebar or Header, but may be used in other Templates as well.
I use the wp_list_pages function in several places.
First, I use it in my main navigation. I have also set several parameters to the function to tell it how to behave:
<?php wp_list_pages('post_title&depth=1&title_li=&meta_key=navigation&meta_value=main'); ?>
I have set my main navigation to display my top level pages using the post title and displayed as a list.
I have also designated some top level pages as “main navigation” only via my custom fields:

Second, I use it in my sidebar to display my sub-page navigation.
Here, I have used an if/else statement to display my “lecture” sub-page navigation with it’s headline only if “lecture” sub-pages exist:
<!-- Begin Lectures --> <?php //list sub-pages even if on a sub-page >if($post->post_parent) $children = wp_list_pages("title_li=&child_of=".$post->post_parent."&echo=0&meta_key=navigation&meta_value=lecture" ); else $children = wp_list_pages("title_li=&child_of=".$post->ID."&echo=0&meta_key=navigation&meta_value=lecture"); if ($children) { ?> <h3>Lectures</h3> <ul><?php echo $children; ?></ul> <?php } ?> <!-- End Lectures -->
See Also: http://codex.wordpress.org/Template_Tags/wp_list_pages#List_subpages_even_if_on_a_subpage
The Loop
The Loop is used by WordPress to display each of your posts. Using The Loop, WordPress processes each of the posts to be displayed on the current page and formats them according to how they match specified criteria within The Loop tags. Any HTML or PHP code placed in the Loop will be repeated on each post.
— http://codex.wordpress.org/The_Loop
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Mauris viverra dignissim velit, varius pretium massa varius quis:
<!-- START CONTENT --> <?php if (have_posts()) : ?> <div id="content"> <h2 class="breadcrumb">Welcome to Seattle Central Community College</h2> <div class="post-box"> <p>This portion of the <a href="http://www.premiumdw.com/">Premium Design Works</a> website is dedicated to and written for the Web Design & Development students at <a href="http://seattlecentral.edu/" target="_blank">Seattle Central Community College</a>.</p> </div> <?php while (have_posts()) : the_post(); ?> <div class="post-box"> <h3 id="post-<?php the_ID(); ?>"><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>"><?php the_title(); ?></a></h3> <p class="postmetadata"><small>Posted on <?php the_time('F jS, Y') ?> in <?php the_category(', ') ?> with <?php comments_popup_link('No Comments', '1 Comment', '% Comments'); ?></small></p> <?php the_content('More »'); ?> <?php edit_post_link('Edit this entry.', '<p><small>', '</small></p>'); ?> </div> <?php endwhile; ?> <?php if(function_exists('wp_pagenavi')) { wp_pagenavi(); } ?> </div> <?php endif; ?> <!-- END CONTENT -->
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Mauris viverra dignissim velit, varius pretium massa varius quis:
<!-- START CONTENT --> <div id="content"> <?php if (have_posts()) : while (have_posts()) : the_post(); ?> <div id="post-<?php the_ID(); ?>"> <h2 class="breadcrumb"><?php if (function_exists('bcn_display')) { bcn_display(); } ?></h2> <?php the_content('<p class="serif">More »</p>'); ?> <?php edit_post_link('Edit this entry.', '<p class="clear"><small>', '</small></p>'); ?> <?php link_pages('<p><strong>Pages:</strong> ', '</p>', 'number'); ?> <p><a href="#" onclick="printpage()"><img class="print" src="http://www.premiumdw.com/SCCC/wp-content/images/icon-print.gif" alt="Print Page" title="Print Page" /></a></p> </div> <?php endwhile; endif; ?> <?php comments_template(); ?> </div> <!-- END CONTENT -->
Using Multiple Loops
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Mauris viverra dignissim velit, varius pretium massa varius quis:
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Mauris viverra dignissim velit, varius pretium massa varius quis:
<!-- BEGIN LOOP ONE --> <div id="home-about"> <?php if (have_posts()) : while (have_posts()) : the_post(); ?> <div id="post-<?php the_ID(); ?>"> <?php the_content('<p class="serif">Read the rest of this page »</p>'); ?> </div> <?php endwhile; endif; ?> <?php edit_post_link('Edit this entry.', '<p><small>', '</small></p>'); ?> </div> <!-- END LOOP ONE --> <!-- BEGIN LOOP TWO --> <div id="home-latest"> <?php rewind_posts(); ?> <?php query_posts('category_name=projects&showposts=1'); ?> <?php if (have_posts()) : while (have_posts()) : the_post(); ?> <h2 id="post-<?php the_ID(); ?>"><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>"><?php the_title(); ?></a></h2> <?php the_content('Read the rest of this entry »'); ?> <?php endwhile; endif; ?> <?php edit_post_link('Edit this entry.', '<p><small>', '</small></p>'); ?> </div> <!-- END LOOP TWO -->
The CSS File
WordPress relies heavily on the presentation styles within CSS. With the introduction of WordPress v1.5 Themes, your layout options haven’t just expanded, they’ve exploded! WordPress has made it easier than ever to change your website look, and opened up the field even more to help you create your own Theme and page layout.
— http://codex.wordpress.org/CSS
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Mauris viverra dignissim velit, varius pretium massa varius quis:
/* Theme Name: premiumdw Description: This is a theme your mom would love. Version: Author: Premium Design Works Author URI: http://www.premiumdw.com/ */ * { border: 0; margin: 0; padding: 0; } a {text-decoration: none;} textarea, input, select { border: 1px solid #bbb; } /* BEGIN HEADER */ #header { background: url(images/bg-header.gif) no-repeat top center; clear: both; height: 184px; width: 900px; margin: 20px auto 0 auto; } #logo { float: left; padding: 75px 0 0 80px; text-align: left; } #utility { padding: 70px 75px 0 0; text-align: right; } #search { text-align: right; padding: 20px 75px 0 0; } #search input { width: 130px; height: 16px; background-image: url(http://www.premiumdw.com/SCCC/wp-content/themes/premiumdw/images/red.gif); border: 1px solid #FFF; color: #FFF; } #search .submit { width: 25px; height: 20px; border: none; background-image: url(http://www.premiumdw.com/SCCC/wp-content/themes/premiumdw/images/searchicon.gif); } #utility li { list-style-type: none; display:inline; font: 10px/18px "Arial", sans-serif; text-transform: uppercase; margin: 0 0 0 10px; color: #FFF; } #utility li a { color: #FFF; border-bottom: none; } #utility li a:hover { color: #FFF; border-bottom: 1px solid #FFF; } #date { font: 12px/14px "Arial", sans-serif; text-align: right; padding: 34px 75px 0 0; color: #FFF } /* END HEADER */ /* BEGIN NAVIGATION */ #nav { font: 14px "Arial", sans-serif; width: 900px; margin: 0px auto 0 auto; } #nav ul { width: 810px; height: 25px; padding-top: 12px; margin: 0px auto 0 auto; border-bottom: 1px solid #000; } #nav li { float: left; list-style: none; text-align: center; width: 115px; } #nav li a { color: #bd2025; } #nav li a:hover { color: #bd2025; border-bottom: 1px solid #ddd; } #nav li.current_page_item a { color: #bd2025; border-bottom: 1px solid #ddd; } #nav li.current_page_item a:hover { color: #bd2025; border-bottom: 1px solid #ddd; } #nav li.current_page_parent a { color: #bd2025; border-bottom: 1px solid #ddd; } #nav li.current_page_parent a:hover { color: #bd2025; border-bottom: 1px solid #ddd; } /* END NAVIGATION */ /* BEGIN MIDDLE */ #middle { clear: both; width: 750px; margin: 10px auto 0 auto; padding: 0 75px 0 75px; } /* BEGIN SIDEBAR */ #sidebar { float: right; width: 170px; padding-bottom: 20px; } #sidebar p, #sidebar ol, #sidebar ul { font: 10px "Verdana", sans-serif; color: #999; line-height: 150%; margin: 0px 0px 10px 0px; } #sidebar h3, #sidebar h2 { border-bottom: 1px solid #ddd; color: #bd2025; font: 14px "Arial", sans-serif; margin: 5px 0 5px 0; text-align: left; } #sidebar li { background: url(images/side_li.gif) no-repeat 0px 6px; line-height: 150%; list-style: none; padding: 0 0 0 7px; margin-bottom: 4px; } #sidebar li a { border-bottom: none; color: #000; } #sidebar li a:hover { border-bottom: 1px solid #ddd; color: #000; } #sidebar li a:hover { color: #bd2025; } #sidebar li.current_page_item a { color: #000; border-bottom: 1px solid #ddd; } #sidebar li.current_page_item a:hover { color: #bd2025; border-bottom: 1px solid #ddd; } #sidebar img, #sidebar iframe { padding: 5px; margin: 5px 0; border: 1px solid #ddd; background: #fff } /* END SIDEBAR */ /* BEGIN CONTENT */ #content { float: left; width: 530px; } #content h2 { clear: both; font-weight: bold; border-bottom: 1px solid #ddd; color: #bd2025; font: 18px "Arial", sans-serif; margin: 0 0px 10px 0; } #content h2 a { margin-right: 3px; border-bottom: none; color: #bd2025; } #content h2 a:hover { margin-right: 3px; color: #bd2025; } .breadcrumb a { margin-right: 10px; } #content h3 { clear: both; color: #bd2025; font: 16px "Arial", sans-serif; font-weight: 400; margin-bottom: 4px; } #content h3 a { border-bottom: none; color: #bd2025; } #content h3 a:hover { border-bottom: 1px solid #ddd; color: #bd2025; } #content h4 { clear: both; color: #000; font: 14px "Arial", sans-serif; font-weight: bold; margin-bottom: 4px; } #content h4 a { border-bottom: 1px solid #ddd; color: #000; } #content h4 a:hover { border-bottom: 1px solid #ddd; color: #000; } #content p { color: #000; font: 12px/18px "Arial", sans-serif; margin: 0 0 10px 0; } #content p a { border-bottom: 1px solid #ddd; color: #000; } #content p a:hover { color: #bd2025; } #content ul { color: #000; font: 12px/18px "Arial", sans-serif; margin: 0 0 10px 0; } #content ul li { background: url(images/content_li.gif) no-repeat 5px 8px; line-height: 150%; list-style: none; padding: 0 20px; margin: 0 0px 2px 0px; } #content ul li a { border-bottom: 1px solid #ddd; color: #000; } #content ul li a:hover { color: #bd2025; } #content ol { color: #000; font: 12px/18px "Arial", sans-serif; margin: 0 0 10px 0; padding: 0 15px; } #content ol li { line-height: 150%; margin: 0 0px 2px 10px; } #content ol li a { border-bottom: 1px solid #ddd; color: #000; } #content ol li a:hover { color: #bd2025; } #content blockquote, #content pre { padding: 15px; border: 1px solid #ddd; margin: 0px 0px 10px 0px; overflow:auto; } #content blockquote h3 { color:#000000; } #content label { color: #bd2025; font: 12px/18px "Arial", sans-serif; } #content iframe { padding: 4px; border: 1px solid #ddd; background: #fff; margin: 0 0 10px 0; } #content img { padding: 4px; border: 1px solid #ddd; background: #fff; } .wp-caption-text { text-align: center; } .alignnone { margin-bottom: 10px; } .alignleft { float: left; margin: 0 10px 10px 0px ; } #previous_image a, #next_image a { border-bottom: none; } .alignright { float: right; margin: 0 0px 10px 10px; } .attachment-thumbnail, .size-thumbnail { padding: 5px; border: 1px solid #ddd; } #content img.print { float: right; border: none; clear:both; margin-bottom: 20px; } #content object { margin: 0 0 10px 0px ; /*border: 1px solid #ddd;*/ background: #fff } #content pre { max-height: 300px; font-size: 12px; padding: 10px; margin: 10px 0px; overflow: auto; } #content p.wp-caption-text { margin-top: 10px; font: 10px/12px "Arial", sans-serif; } .clear { clear:both; height: 0px; } /* POST ITEMS */ .post-box { border-bottom: 1px solid #ddd; margin-bottom: 10px; overflow: auto; } /* GALLERY ITEMS */ #gallery-box { margin-bottom: 25px; } .gallery { margin: auto; } .gallery-item { float: left; margin: 5px 3px 5px 0; text-align: center; } #content p.smallattachment a, #content dl.gallery-item a { border-bottom: none; } .gallery img { } .gallery-caption { margin-left: 0; } /* PAGINATION */ div.wp-pagenavi { float: right; font: 12px/18px "Arial", sans-serif; margin: 10px 0 20px 0; border-bottom: none; } .wp-pagenavi a, .wp-pagenavi a:link { padding: 2px 4px 2px 4px; margin: 2px; text-decoration: none; border: 1px solid #ddd; color: #000000; background-color: #FFFFFF; } .wp-pagenavi a:hover { border: 1px solid #ddd; color: #000000; background-color: #FFFFFF; border-bottom: none; } .wp-pagenavi span.pages { padding: 2px 4px 2px 4px; margin: 2px 2px 2px 2px; color: #000000; border-bottom: none; background-color: #FFFFFF; } .wp-pagenavi span.current { padding: 2px 4px 2px 4px; margin: 2px; font-weight: bold; border-bottom: none; color: #000000; background-color: #FFFFFF; } .wp-pagenavi span.extend { padding: 2px 4px 2px 4px; margin: 2px; border: none; color: #000000; background-color: #FFFFFF; } /* BEGIN COMMENTS */ #comments-head { border-bottom: 1px solid #ddd; } #comments-box { clear: both; } #comments-box ol { padding: 0; } #comments-box ol li.depth-1 { list-style-type:none; padding: 10px 0; border-bottom: 1px solid #ddd; } #comments-box ul li.depth-2 { list-style-type:none; padding-top: 10px; } #comments-box cite { font-weight:bold; font-size:14px; } .comment-author { margin-bottom: 2px; } .comment p { clear:both } .reply { font-size:10px; } .comment-meta { /*display:none;*/ font-size:10px; } .avatar { float: left; margin: 0 10px 10px 0; } /*BEGIN FOOTER */ #footer { background: url(images/bg-footer.gif) no-repeat top center; clear: both; height: 100px; width: 900px; margin: 0 auto 20px auto; padding: 6px 0 0 0; font: 9px/14px "Arial", sans-serif; text-align: center; color: #FFF; } #footer a { color: #FFF; border-bottom: none; } #footer a:hover { color: #FFF; border-bottom: 1px solid #FFF; }
4 Comments:
Leave a Comment:












Here is a nice 3-part video tutorial (Screencasts #25-27) on Designing for WordPress. This takes you from install to customizing an existing template.
http://css-tricks.com/video-screencasts/25-designing-for-wordpress-part-one/
CSS-Tricks has a ton of other podcast videos that are helpful.
Doesn’t the urchin tracker in your footer include that came with your theme mess with your analytics?
Yes, all of you should delete my analytics code from the footer file.
for those of you who may need a little help with PHP (like me) I found this great little cheat sheet: http://www.addedbytes.com/cheat-sheets/php-cheat-sheet/
you can download a PDF of it and refer to it whenever you need it. Its good to keep the URL handy since it explains the document “chunks” to you in case you really really need help with PHP (like me.)