Files Needed To Create A WordPress Theme
What Makes Up A WordPress Theme
So I decided to build my own wordpress theme for this blog. The main reason for this is so I can make it exactly how I want it and in the future I can change it to exactly what I need.
Now to start off I need to find out whats involved in making a wordpress theme. A theme is made up of the basic wordpress pages and a style sheet to style these pages. As long as you use the wordpress frame functions in these files then your theme will be able to work exactly like every other theme. The standard pages you need for a wordpress theme are:
This page as it’s name states is the page that will be displayed on a 404 HTTP header error.
A 404 error is when the server could not find the page that was requested by the client. This can be because of the link to the page or page has disappeared.
On a 404 the wordpress framework will see that there was an error and display this page. Here you can include other pages such as the header and footer to make it look similar to the other pages.
On this page will be where you put the loop to get the comments for the current post, this will go into the the single.php page so it will be displayed on a single post. The reason why you put this in a separate php page is so you can put comments on pages as well as posts.
This will loop through all the comments and display these to the user, if there are no comments it should display a message so you know this post has no comments.
The comment form to add a new comment should also be in page. So make sure you create a form to post a comment which should include the visitors name, email, website and comment.
You can add the comment hooks into the comment form which will just before the end
tag so you can add additional fields/functionality to the comment form.
This file is a template for the footer of the page. This will be in a footer file so that it will be the same on each page.
The footer file can be called by using the in-built function of
The footer file should include the footer hook which should be placed just above the end of the body tag.
The functions.php page is a page where you can put any custom functions which can be called by any of the other pages in the wordpress blog. You can put anything you want in here and apply hooks to make sure these functions run at the right moment.
The header file will be similar to the footer but for the content of the file. It is similar as it is called from the post page by using
you can also add hooks to the headers by using the
The index file is going to be by default the first page which will be called from the wordpress framework. In here can be anything you want but as this is going to be used as a blog you would normally put in your call for the header
then your content, then the sidebar
, then the footer get_footer().
The content should be getting the blog posts and displaying it to the visitor, this should be getting a certain number of posts and looping around them to display the post titles and post contents.
The search page is a template which is called when a search is performed on the site. This should get results from the search and display these posts that match to the user.
For best practice this should be in the same layout as your index page for consistency.
This page is used as the sidebar template which can be called by using the wordpress function
. The best elements to have in this template is links to your most recent content or your most popular content.
It is also common place to have ads in this section, this is because they will appear on every page and are above the fold so will always be seen. But you shouldnt put ads in your sidebar unless you already have a large set of readers.
The single page is the template page to be used on single posts this is where you will display your page title, content, images and where the user will enter comments. Having the user enter comments means this will be a good place to display the comments on the posts.
The style.css is the file where you will put the default styles for your blog. There are CSS comments you can put at the top of the file so that wordpress will know this is the default style sheet to use. The content you put in the comments will appear on the theme selector page so you can identify the theme.
The content you will need in the comments is the theme name, the theme uri, theme description, author, version and tags.
/* Theme Name: Paulund WP Theme Theme URI: http://www.paulund.co.uk/ Description: A minimalistic, simple theme for WordPress by paulund.co.uk Author: Paulund Version: 1.0 Tags: minimalistic, simple, widgets, sidebar, elegant */
Subscribe To Newsletter
Get weekly updates to your email