Creating your own WordPress template is not as complicated as you may think. A lot of people suggest to use the default template and modify that. Personally I disagree. If you’re capable of writing your own HTML markup and CSS then all you need to know are the template tags and the wordpress loop. The only theme file I would recommend copying is the comments.php file, and I’d recommend using the Classic theme’s file, not the default one.
You can create the design however you want. Work out how you want the main elements of your blog to be (posts, category list, pages, archives list if you want it, comments etc). Take your design and, ignoring any theme for the time being, code your design up into HTML and CSS. The only thing to bear in mind with your markup is the following:
You can split your new page up into at least 3 maybe 4 sections. You have your header, containing the generic top content shown on every page, footer, the generic bottom content on every page, your sidebar, if it doesn’t/cannot fit into the header or footer, and the main index page that contains everything which doesn’t fit into these files. Each of these files must be called header.php, footer.php and sidebar.php and index.php.
In your index.php file you need to insert the following tags inside PHP tags:
This will then set up the index file to pull in the header, sidebar and footer in the relevant places.
Around your post we need to add the loop code. Right before the post starts (eg. the opening div tag that surrounds the post), insert the code
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
Then after your post markup close the loop using
<?php endwhile; endif; ?>
You will then want to add the following tags to help construct the dynamic post:
There are also plenty of other tags you may want to use. A couple of more popular ones are
If your design is quite simple and your single post page is virtually identical to the front page then you may want to just have the index.php theme file power both pages. If so then you’ll also need to add the following tag just before the closing loop code that you added earlier:
<?php comments_template(); ?>
This will then pull in the comments.php file, which as mentioned earlier, I recommend you just copy the comment.php theme file from the Classic theme, and we can look at modifying that later.
To define your theme and make WordPress recognise it, you need to add the following to the top of your CSS file (which you need to call style.css).
/*
Theme Name: Put Your Theme Name Here
Theme URI: Put Your Site Address Here
Description: Give it a short description
Version: 1.0
Author: Your Name Here
*/
This information is read by WordPress and when you’ve uploaded your new theme (into its own directory under wp-content/themes/) and go to Admin – Design, you’ll see your theme as an option to be selected. If you want a thumbnail displaying too then create a screenshot of the theme and add it into your theme directory with the filename of screenshot.png or screenshot.jpg. This will also be automatically displayed by WordPress.
Next week I’ll write about how to edit your header, footer and sidebar files, ready to then set your theme live.
Author comments are in a darker gray color for you to easily identify the posts author in the comments
[...] Create Your Own Template Creating your own WordPress template is not as complicated as you may think. A lot of people suggest to use the default template and modify that. Personally I disagree. If you’re capable of writing your own HTML markup and CSS then all you need to know are the template tags and the wordpress loop. The only theme file I would recommend copying is the comments.php file, and I’d recommend using the Classic theme’s file, not the default one. [...]
[...] Create Your Own Template. Перевод: [...]
[...] week I explained how to set up your index.php file for your new template. This week I’ll cover the included files, ie. the header, footer and [...]
[...] Create Your Own Template [...]
[...] Create Your Own Template [...]
[...] few weeks ago I wrote about to create your own template for WordPress. A type of design growing in popularity is the Magazine style theme. Probably because [...]
[...] Create Your Own Template [...]
Comments are closed since this post is older than 30 days. However, you can continue this discussion in our popular Blogging Forums
Hello, I am blogger but this is new to me. Till now I used free templates from the net. But now I`ll try to make my own unique template. Thanks for th information!
Everyone bloging should know thing imo. A personal/custom template is a must if you ask me…
This is a very useful topic for new designer of WP.
Thank you!
Cheers for the comments everyone, don’t forget, there’s more to come next week
My Wordpress themes are mostly ready made but I modify them for my needs and to be somewhat unique to others using same theme. It doesn’t take too much of my time but I really want to have my very own theme that I build from ground up.
Great article, thank you so much
Your article is very useful. I have bookmarked it. I use to always find this whole Template creation very confusing and big task. but you seem to have simplified it beautifully. Thanks I will surely let you know after I have applied your procedure.
I always wanted to learn about this and this is a well-timed post.
Thanks for this and waiting for more, next week
thanks for tips, now it’s easier for me to create a template
This is a great tutorial on creating a wordpress theme. Most tutorials I come across are more academic in nature and not really that helpful.
Your voice is concise and stresses exactly what you need to do to get the bits put together in an index.php page.
I will definitely be following this series, subscribed!
Chuck
Thanks for the tutorial. I’m horrible at creating themes, so I look at other themes code and just copy-paste them. And then I edit them.
Thanks. I would like to pimp my own wp themes.
hey!!!!!!!!!! I want to be a template maker because I think you will like my designs and I was drawing them in my designer book so that’s all byeeeeeeeee!!!!!!!!!!!!!!!!!!!!!!