Dissection of a WordPress theme: Part 1

Apr 12, 2005 | Tags: , , , | Written by Administrator

Life as a WordPress blogger has become remarkably easy. If you can hold a mouse and follow instructions then you're most of the way towards carving out your own niche on the internet. A fresh installation gives you a powerful and attractive system with minimal effort, and with a little luck you can be blogging in under half an hour.

Despite the availability of hundreds of themes, and the general goodness of the default Kubrick theme, sometimes you just want to give your blog that personal touch, and the only way to do this is by going under the hood and having a look around.

A month in to running a WordPress-based website and I find myself doing the very same thing. None of the themes were exactly what I was looking for, and after investigating the internals of WordPress I realised it was a lot more involved than it initially appeared. I could certainly imagine a beginner being overwhelmed by the mass of acronyms and incongruent technologies.

With this in mind I decided to write a guide that would help not only myself, but might also help others who have been put off trying to experiment with WordPress. I make no claims of being a style guru and will rely on common sense and basic design principles.

In writing this I will assume a rudimentary knowledge of HTML and CSS. I will attempt to annotate all the important parts. The guide will begin slowly, but should speed up once a level of comfort has been reached.

Rather than starting a theme from scratch, and having to explain everything, I will instead focus on dissecting an existing theme and explaining parts as they are required. From a personal point of view, I find it easier to learn things by focussing on the small details, and ignoring everything else. In this instance I will be using the default WordPress 1.5 theme Kubrick.

Diagrams will be used where necessary, and annotated code will be available. The different stages will be available to download using the links in the menu on the right of each page.

The first part of this guide is split into two steps, and will result in a basic site with a minimum of style - it will be fully usable, if not particularly attractive. Future guides will dissect the theme further, and make it look more attractive.

Step 1: Pulling it apart

The first step is to make a copy of the default theme. All themes are found in the wp-content/themes directory. Here Ive simply copied the default theme and renamed it to MonkeyMagic:

copying

Cleaning the theme

Now we need to clean the theme in order to make it our own. Every theme has a piece of information that tells WordPress what the theme is called, who wrote it, as well as containing other details such as version and description. This information is displayed by WordPress in the administration presentation section, and a theme will not work without it. The information is defined at the start of the file style.css. Its important that we dont get confused with the existing Kubrick style, so the best thing is to delete the style.css, and create a new one:

/*
Theme Name: MonkeyMagic
Theme URI: http://urbangiraffe.com/
Description: Theme dissection example
Version: 1.0
Author: John Godley
Author URI: http://urbangiraffe.com/
*/

Make sure you save this in the MonkeyMagic theme directory, and not the default one!

Removing Kubrick

Next we need to remove some Kubrick specific styles in the file header.php. Dont worry about the details here, its just necessary we lose all styles.

Delete from line 17 to 48 (inclusive).

  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  2. <html xmlns="http://www.w3.org/1999/xhtml">
  3.  
  4. <head profile="http://gmpg.org/xfn/11">
  5.     <meta http-equiv="Content-Type" content="<?php bloginfo('html_type'); ?>; charset=<?php bloginfo('charset'); ?>" />
  6.  
  7.     <title><?php bloginfo('name'); ?> <?php if ( is_single() ) { ?> &raquo; Blog Archive <?php } ?> <?php wp_title(); ?></title>
  8.  
  9.     <meta name="generator" content="WordPress <?php bloginfo('version'); ?>" /> <!-- leave this for stats -->
  10.  
  11.     <link rel="stylesheet" href="<?php bloginfo('stylesheet_url'); ?>" type="text/css" media="screen" />
  12.     <link rel="alternate" type="application/rss+xml" title="RSS 2.0" href="<?php bloginfo('rss2_url'); ?>" />
  13.     <link rel="alternate" type="text/xml" title="RSS .92" href="<?php bloginfo('rss_url'); ?>" />
  14.     <link rel="alternate" type="application/atom+xml" title="Atom 0.3" href="<?php bloginfo('atom_url'); ?>" />
  15.     <link rel="pingback" href="<?php bloginfo('pingback_url'); ?>" />
  16.  
  17.     <style type="text/css" media="screen">
  18.  
  19.         /* BEGIN IMAGE CSS */
  20.             /*  To accomodate differing install paths of WordPress, images are referred only here,
  21.                 and not in the wp-layout.css file. If you prefer to use only CSS for colors and what
  22.                 not, then go right ahead and delete the following lines, and the image files. */
  23.  
  24.         body        { background: url("<?php bloginfo('stylesheet_directory'); ?>/images/kubrickbgcolor.jpg"); }    <?php /* Checks to see whether it needs a sidebar or not */ if ((! $withcomments) && (! is_single()) && (! is_page())) { ?>
  25.             #page       { background: url("<?php bloginfo('stylesheet_directory'); ?>/images/kubrickbg.jpg") repeat-y top; border: none; } <?php } else { // No sidebar ?>
  26.             #page       { background: url("<?php bloginfo('stylesheet_directory'); ?>/images/kubrickbgwide.jpg") repeat-y top; border: none; } <?php } ?>
  27.             #header     { background: url("<?php bloginfo('stylesheet_directory'); ?>/images/kubrickheader.jpg") no-repeat bottom center; }
  28.             #footer     { background: url("<?php bloginfo('stylesheet_directory'); ?>/images/kubrickfooter.jpg") no-repeat bottom; border: none;}
  29.  
  30.  
  31.             /*  Because the template is slightly different, size-wise, with images, this needs to be set here
  32.                 If you don't want to use the template's images, you can also delete the following two lines. */
  33.  
  34.             #header     { margin: 0 !important; margin: 0 0 0 1px; padding: 1px; height: 198px; width: 758px; }
  35.             #headerimg  { margin: 7px 9px 0; height: 192px; width: 740px; }
  36.         /* END IMAGE CSS */
  37.  
  38.  
  39.         /*  To ease the insertion of a personal header image, I have done it in such a way,
  40.             that you simply drop in an image called 'personalheader.jpg' into your /images/
  41.             directory. Dimensions should be at least 760px x 200px. Anything above that will
  42.             get cropped off of the image. */
  43.  
  44.         /*
  45.         #headerimg  { background: url('<?php bloginfo('stylesheet_directory'); ?>/images/personalheader.jpg') no-repeat top;}
  46.         */
  47.  
  48.     </style>
  49.  
  50.     <?php wp_get_archives('type=monthly&format=link'); ?>
  51.  
  52.     <?php wp_head(); ?>
  53. </head>
  54. <body>
  55.  
  56. <div id="page">
  57.  
  58.  
  59. <div id="header">
  60.     <div id="headerimg">
  61.         <h1><a href="<?php echo get_settings('home'); ?>"><?php bloginfo('name'); ?></a></h1>
  62.         <div class="description"><?php bloginfo('description'); ?></div>
  63.     </div>
  64. </div>
  65. <hr />

Help me to save time by reading these instructions!

If you are asking a question please read the FAQ to see if it has already been answered. All support questions should be directed to the support forum. Thanks!

Share This

Comments (page 14 of 14)

  1. Atof :

    Mar 7, 2008 5:19 am

    Thax a bundle for the gr8 article :D

  2. Technology Rules :

    Feb 15, 2008 3:38 am

    Nice article....thq

  3. John (author) :

    Jan 11, 2008 8:12 pm

    I'm not sure why you'd want search.php to show posts in alphabetical order (surely you want them in search order?), but query_post will return all posts unless you restrict it:

    query_post ('orderby=title&order=asc');

Pings & Trackbacks

82.161.28.62, afterthe.net, allhealth.ca, areblytt.org, arts.bisbee.net, atog.be, axlelabs.thischick.com, bardak.com.ru, beautiful-tears.net, benjoblog.weblogs.us, bentrem.wordpress.com, bingu.net, blog.23corner.com, blog.andymelton.net, blog.benjolo.com, blog.discombobulate.co.uk, blog.jackpate.com, blog.odsoks.co.uk, blog.secretaboutasecret.co.uk, blog.tinyau.net, blogging.typepad.com, blogikirja.net, blogunion.org, bogomo.net, buggy.homeip.net, carloadi.wordpress.com, code.red.lt, compl33t.za.net, cre8d-design.com, creep.lenise.com, cssquestions.wordpress.com, cyxxon.com, dalat.wordpress.com, dev.graymattergravy.com, dingyi.zhuxinquan.com, dlightblogs.com, dwihgt.net, eric.zooco.com.ph, fabflake.com, fake-life.com, gailoverholt.com, gordonbrown77.wordpress.com, gudmann.net, halrager.org, hausderluege.org, hedu.allhyper.com, hooney.net, hucker.net, increseo.com, inforedesign.com, inknplay.com, isice.twbbs.org, javajunkydesign.com, katherinemisegades.wordpress.com, kbps.resounder.org, lavelleweb.com, law.marquette.edu, literalbarrage.org, lorelle.wordpress.com, magik2u.clawz.com, mandrake.liquidblade.com, markmckay.ca, mikael.vastervik.nu, milovanov.deepmix.ru, myblog.vindaloo.com, nerdnotes.brammeleman.org, nyssajbrown.net, okanogan1.com, okaysoul.net, openchoi.com, passband.net, peacechikn.nfshost.com, pg4me.de, photomatt.net, photosbyduncan.com, pias-place.com, pixelinghoney.net, pixelparser.com, planetalinux.blog.br, podboje.road62.com, radioball.net, redclay.xrea.jp, rockersworld.com, rusi.is-a-geek.org, sandbox2.pleth.com, sdrawkcabssa.com, sector40.net, solomonrothman.com, spuriousink.com, summeryfresh.org, tech4ppc.selfip.com, technote.thedeveloperside.com, tekapo.com, test.codo.co.uk, themarketingmom.com, theselfstarters.com, topdownjimmy.beigetower.org, tyj.yutgaubartsei.com, ub52.com, vanus01.host.sk, wagthis.com, weblogtoolscollection.com, wordpr.ectio.us, wordpress.faerycharm.com, wpthemesplugin.com, 12iL.net, akkamsrazor.com, amitpatel.info, anbruradio.org, andresperales.com, autho-rity.info, blogofstupidity.com, brainsprinkles.com, budi.5gigs.com, burningriverstudio.com, carlosdoren.com, chaim.com, clydeshome.net, cottonrohrscheib.com, cyber-bronkx.com, daesik.com, dailyblogtips.com, datarefuge.com, daveschalkboard.com, deget.net, digiscrappingqueen.com, digitallytwisted.biz, distantsignal.com, egor-k.com, emilyrobbins.com, enblogopedia.com, escdotdot.com, gazette.computersandthings.com, gfxdizayn.com, grantpalin.com, icentro.net, ivonson.com, jantzie.com, jdsblog.com, jindol.com, johntolson.co.uk, joselise.com, jou.ufl.edu, klausbravenboer.com, kopress.com, kyid.net, ldrj.com, lpbk.net, marketingloop.com, markfay.id.au, mondoblog.it, myemptymind.com, myheadisarocket.com, napolux.com, nathanwaters.com, netlexfrance.com, newskoo.org, noulakaz.net, officialstation.com, permanentred.com, peterlutek.com, pierce.ctc.edu, pixies.ca, plunker.com, qbicweb.net, rodtempleton.net, ruthstalkerfirth.com, samdevol.com, sampletheweb.com, shaghaghi.net, shsh.ylc.edu.tw, slightlytallerthanaverageman.com, southernfriedmind.com, summerstorm.ca, tittahit.se, tjeerdoo.com, tri-omni.com, tuning.co.in, uowz.com, vandelaydesign.com, visualfuture.com, whincop.com, whogivesfx.com, wickedfire.com, wordpress-it.it, wordpressthemes.com, workingblogger.com, wp-superblog.com, zapgarden.com, xn--bleskrog-i0a.dk, xxiaa.net

Leave a comment


XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <code> <em> <i> <strike> <strong>

Help me to save time by reading these instructions!

If you are asking a question please read the FAQ to see if it has already been answered. All support questions should be directed to the support forum. Thanks!

Home | Software | Terms & Conditions | Sitemap | John Godley © 2008
Close
E-mail It