How Does WordPress Work?

by Steve on January 17, 2009

WordPress is, at its most basic, very simple. It is a PHP script that displays a blog entry, or series of entries based on information contained in the URL. The display is controlled by PHP files that collectively make up a theme.

A Basic Theme

WordPress themes contain at least two files: index.php and style.css. The file index.php controls what goes on the final web page, and style.css controls what the page content looks like. The only reason a style.css file is essential in WordPress themes (you don’t really NEED styles for a bare-bones XHTML web page) is that it contains information in a certain format that WordPress uses to gather theme details like the name, the author of the theme, and so on.

The Index File

The index file is where the magic happens. How much magic depends on the theme designer. The following code placed in an index.php file will generate a series of WordPress posts:

if (have_posts()) :
while (have_posts()) :

In English, what the above code says is, “first, get the header. Then, if the have_posts() function gets some posts, while there are posts in that list, display the content. Then, get the footer.”

Pretty simple, eh? Try it for yourself and see what it looks like. You can get more information on the WordPress Loop or see The Loop in action.

{ 2 comments… read them below or add one }

jeff March 8, 2010 at 11:10 am

Is your blog done? I don’t see any posts since January 2009. I’m wondering if you’ve given up on it?


Steve March 8, 2010 at 12:56 pm

Thanks for asking – no, it’s not done. That said, I’ve been so busy lately I just haven’t had any time to devote to it. Sad excuse, eh? I mean, what’s an hour or so a week?


Leave a Comment

You can use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>