Blog

2

WordPress Theme Lesson 8: Post Thumbnails

In this lesson we’ll go through post thumbnails, a feature introduced in WordPress 2.9. A post thumbnail is an image chosen by the author as the representative image for a post. Having an image to each post makes the site more interesting to look at. Keep in mind that the post thumbnail is not a part of the post’s body content, so it will not appear unless you choose it to.

In our design we want a wide and quite narrow thumbnail above each post on our front page. We also want the same post thumbnail but smaller and square for our featured posts section (the slider we’ll create at the very top of the front page). In this lesson we’ll first add and define these new image sizes and then tell WordPress where to display them. Along the way we will also add some code to exclude images that appear in posts, as not to make the front page look like a mess.

Read more »
1

WordPress Theme Lesson 7: Defining Multiple Widget Areas and Default Wrappings

In this lesson we’ll dig further into widgets by adding multiple widget areas and further customizing them. We are to add three widget areas in the footer, and another widget area in our sidebar. By adding two widget areas in the sidebar, one above and one below the ads element, we give the user flexibility in organizing the sidebar. Especially if the ad element are to be hardcoded in the sidebar.

Defining multiple widget areas require us to write a little more code since we need to identify each area with a name and an ID. At the same time we will also define which wrappings should be used around and in all widgets that are placed in the areas. In the previous lesson when we tried to style widgets in our widget area in the sidebar, we saw that WordPress automatically wraps all widgets inside <li> elements. By WordPress’s standards the sidebar should be an unordered list, and each widget a list item with a yet another list inside for its elements. I myself prefer wrapping widgets in <div>s, to skip the messy work of styling nested lists.

So we need to modify and add code to the templates where our widget areas should appear, in our case the sidebar.php and footer.php, associating each with the registering we do in our functions.php.

Read more »
0

Art in Progress

I promised myself that this blog wouldn’t be filled with posts only about code and webdesign – but artwork as well. So to break up the coding posts I thought I’d post pieces to show that I haven’t forgot to draw amidst all the coding.

In the first piece, to the left, you’ll notice a little boy in bed afraid to open his eyes. No wonder, what the heck is going on with that teddy bear gone mad and the tentacles coming out of the night stand drawer? That’s just a small part of the weirdness. The second piece, to the right, seems like two pieces from a pretty normal painting. A fireplace and some bunny slippers. But who, or rather what, is sitting inside the blankets and wearing those slippers – and why?

1

WordPress Theme Lesson 6: Styling our Theme With CSS

In this lesson we’ll focus entirely on CSS to style our theme. In Lesson 3 we wrote some very basic layout styling to make it easier to separate the elements from each other, but now it’s time to do it properly. We will also style specific things in the templates we created in the previous lesson.

What we will do is to style the content in our sidebar, both widgets and the hard-coded parts, add more styling to the header and footer as well as our templates such as comments and single post templates.

Read more »
5

WordPress Theme Lesson 5: Creating WordPress Templates

In lesson 1 we learned that WordPress has a hierarchy of templates to choose from, depending on the situation, and the index.php is the final fallback. As for now our theme consists of the index.php only, which means that this template will be used at any situation, whether the user is on the front page, clicked a post or a category. It’s time to create more templates to our themes, most importantly the single post template with the comments template.

In this lesson we will look at the single post view (single.php), single page view (page.php), the comments template (comments.php), archive template (archive.php), the search result template (search.php), and finally the 404 Error template for whenever the user has reached an URL that doesn’t exist (404.php). It’s a pretty long post with codes for each template, but don’t be intimidated – in most of the templates we just copy the index.php, rename the file and makes some small modifications. These are the basic templates for a well-working theme, but there exist many more. You are free to create as many of WordPress templates as you wish, but the single post, single page, and comments templates are the important ones.

Read more »
0

WordPress Theme Lesson 4: Defining Widget Areas and Creating our Functions File

Now that we have a theme that displays posts on the front page, it’s time to add some meaningful content in the sidebar. WordPress allows users to decide what to have in the sidebar using widgets. Using a GUI in WordPress admin users can place, remove and rearrange elements without the need of editing any theme files.

In this lesson we will define a widget area – a place where the user can arrange widgets. To do so we need to write some code in our sidebar.php, but also tell WordPress that our theme support widgets by creating the functions.php and adding some code. The functions.php is a file we will revisit frequently during this tutorial since it’s here we store our PHP functions and WordPress configurations.

Read more »
0

WordPress Theme Lesson 3: The Loop and Basic CSS

In this lesson we will do two major things. First we will write some CSS to set up the basic layout as to make it easier to visually separate the different parts from each other. We will center the middle content, restrict it to a certain width, place the content to the left and the sidebar to the right, and position the header on top and footer at the bottom. Secondly we will be querying some more advanced WordPress information – posts. The front page on our site are to display published posts, ordered by the date they was published.

So far in this tutorial we have activated the theme and the preview of our front-end is not much to look at. Let’s fix that by setting up some basic CSS.

Read more »
1

WordPress Theme Lesson 2: Creating Files and Activating the Theme

In this lesson we’ll finally get started with creating files, write some code and activate the theme in WordPress so we can see it in action. We will begin with very basic HTML and some dummy content, but we’ll establish the structure and begin to query WordPress for some information such as the blog’s name and stylesheet directory. In later lessons we’ll query WordPress for much more information, such as posts and widgets.

In the previous lesson I showed you the design and the HTML structure (Click here for the visual representation given in the previous lesson) we are to create, and how it is split into separate files – the header.php, sidebar.php and sidebar.php, and the core index.php template which includes the previously mentioned templates. We also need to create the stylesheet, style.css because all the details of a WordPress theme are contained within the stylesheet.

Read more »