Announcement!

Bid Oh Bid Directory - Bid your link to get higher position now!

You are reading Make your Own Wordpress Theme - Part 2. To read other parts, click on the link below.

Part 2 will be more detail on things and functions needed to put in your Wordpress header file. Open your header.php file.

Code (php)
  1.  
  2. <html>
  3. <head>
  4. <title>My Wordpress Theme</title>
  5. </head>                 
  6. <body>
  7. <div id="wrapper">
  8. <div id="header">
  9. </div> <!– close header –>
  10. <div id="content">
  11.  

Now, we are going to put wordpress functions into our header. We start with the title first.

Because Wordpress is dynamic, so we can make our site has dynamic title by put this <?php wp_title(); ?> between <title> and </title>. This tag is use to call the title of the page.

Code (php)
  1.  
  2. <title><?php wp_title(); ?></title>
  3.  

But to make the title more interesting, we use the title tag with other PHP codes.

Just copy and paste this code between <title> and </title>.

Code (php)
  1.  
  2. <?php wp_title(); if (function_exists(‘is_tag’) and is_tag()) { ?>Tag Archive for <?php echo $tag; } if (is_archive()) { ?> archive<?php } elseif (is_search()) { ?> Search for <?php echo $s; } if ( !(is_404()) and (is_search()) or (is_single()) or (is_page()) or (function_exists(‘is_tag’) and is_tag()) or (is_archive()) ) { ?> at <?php } ?> <?php bloginfo(‘name’); ?> - <?php bloginfo(‘description’); ?>
  3.  

And it will look like this

Code (php)
  1.  
  2. <title>
  3. <?php wp_title(); if (function_exists(‘is_tag’) and is_tag()) { ?>Tag Archive for <?php echo $tag; } if (is_archive()) { ?> archive<?php } elseif (is_search()) { ?> Search for <?php echo $s; } if ( !(is_404()) and (is_search()) or (is_single()) or (is_page()) or (function_exists(‘is_tag’) and is_tag()) or (is_archive()) ) { ?> at <?php } ?> <?php bloginfo(‘name’); ?> - <?php bloginfo(‘description’); ?>
  4. </title>
  5.  

The next thing that we will do is to import our stylesheet file to be use in our theme.

Code (php)
  1.  
  2. <?php bloginfo(’stylesheet_url’); ?>
  3.  

This tag will return our stylesheet url. Put this tag after </title>. But make sure that your CSS file named with style.css.

Code (php)
  1.  
  2. <style type="text/css" media="screen">
  3. <!– @import url( <?php bloginfo(’stylesheet_url’); ?> ); –>
  4. </style>
  5.  

There are some other tags that we need to put in. Just copy this code below and paste it before </head>

Code (php)
  1.  
  2. <link rel="stylesheet" href="<?php bloginfo(’stylesheet_url’); ?>" type="text/css" media="screen" />
  3. <link rel="alternate" type="application/rss+xml" title="<?php bloginfo(’name’); ?> RSS Feed" href="<?php bloginfo(’rss2_url’); ?>" />
  4. <link rel="pingback" href="<?php bloginfo(’pingback_url’); ?>" />
  5. <meta name="generator" content="WordPress <?php bloginfo(’version’); ?>" />
  6.  

Last thing that we need is to put <?php wp_head(); ?> in header.php.

Finally, your header.php file will look like this.

Code (php)
  1.  
  2. <html>
  3. <head>
  4. <title>
  5. <?php wp_title(); if (function_exists(‘is_tag’) and is_tag()) { ?>Tag Archive for <?php echo $tag; } if (is_archive()) { ?> archive<?php } elseif (is_search()) { ?> Search for <?php echo $s; } if ( !(is_404()) and (is_search()) or (is_single()) or (is_page()) or (function_exists(‘is_tag’) and is_tag()) or (is_archive()) ) { ?> at <?php } ?> <?php bloginfo(‘name’); ?> - <?php bloginfo(‘description’); ?>
  6. </title>
  7.  
  8. <style type="text/css" media="screen">
  9. <!– @import url( <?php bloginfo(’stylesheet_url’); ?> ); –>
  10. </style>
  11.  
  12. <link rel="stylesheet" href="<?php bloginfo(’stylesheet_url’); ?>" type="text/css" media="screen" />
  13. <link rel="alternate" type="application/rss+xml" title="<?php bloginfo(’name’); ?> RSS Feed" href="<?php bloginfo(’rss2_url’); ?>" />
  14. <link rel="pingback" href="<?php bloginfo(’pingback_url’); ?>" />
  15. <meta name="generator" content="WordPress <?php bloginfo(’version’); ?>" />
  16.  
  17. <?php wp_head(); ?>
  18.  
  19. </head>
  20. <body>
  21. <div id="wrapper">
  22. <div id="header">
  23. </div> <!– close header –>
  24. <div id="content">
  25.  

Next, Part 3 - Index . [tags]diy, how to, skin, theme[/tags]

Subscribe me feed! If you enjoyed this article, get latest updates via RSS feed or by email.

13 Responses to “Make your Own Wordpress Theme - Part 2”

  1. azraai
    December 14th, 2006 | 12:40 am

    dari ko wat tutorial mcm ni. baik ko terang satu-satu tag template WP. bukan semua org faham kal wat tutorial mcm ni.

  2. Undertypo
    December 14th, 2006 | 8:40 am

    Yeah, I think you better explain more about all the tag that you use in header.php.

    If there is A newbie that trying to create a wordpress theme, do you expect he just copy and paste all the code? At least he/she need some explanation regarding all the coding.

  3. novatech
    December 14th, 2006 | 12:53 pm

    i think this is already good, the structure of theme.
    go read youself at wp codex for more explaination for the function used
    “good programmer learn from examples”, and always use multiple sources
    good luck :)>-

  4. dinswok
    December 14th, 2006 | 4:56 pm

    yeah… this is just the rough explanation. Any details regarding the meaning of each code can be found somewhere else. But… hmmm.. i wish i could read all those details here. Haha!

  5. CypherHackz
    December 14th, 2006 | 6:39 pm

    [Comment ID #15604 Will Be Quoted Here]

    okies. aku dah start kat part 3. sudi2 la men’review nyer. :d

    [Comment ID #15610 Will Be Quoted Here]

    same2. check out my 3rd part. :)

  6. goggle
    February 6th, 2007 | 2:03 pm

    A better explanation of the tags would be really useful :)

  7. CypherHackz
    February 6th, 2007 | 5:35 pm

    for the tags, you can learn them here:

    http://codex.wordpress.org/Template_Tags/

  8. mr.eims
    April 1st, 2008 | 3:19 pm

    hurm..bagus..bagus..ko nie rajin btol..hehe
    mesti ko dah expert ngn sume tags2 dlm WP nie..hehe..

    buat la theme utk latest WP plak..:)

  9. rohaza
    June 24th, 2008 | 3:03 pm

    yang ni dah cukup bagus…

  10. Anne
    June 27th, 2008 | 2:25 am

    oh my poor brains..though that article is really helpful but PHP code from “Part 2 - Header” is really awesome.Anyway, Thank you!!!

  11. Tutoriale wordpress » DIY: Wordpress Themes
    October 17th, 2008 | 5:00 pm

    [...] Part 2 - Header [...]

  12. Senpai
    November 24th, 2008 | 11:16 pm

    i cant proceed part 2…hard la

  13. Dana
    December 2nd, 2008 | 1:40 am

    Thank you for this tutorial, though it may behoove you to actually listen to your audience. You have multiple requests here for better explanation of the information presented. Though the lesson may be straight forward for you, I’m assuming you wrote this tut for your readers to read…not simply for yourself.

    I was surprised that you simply said “copy and paste this code”. That doesn’t necessarily constitute a tutorial and judging by your readers’ comments, they’re letting you know that, as well. Taking into account feedback from your audience will only strengthen you…you may want to listen.

Leave a Reply