How Does WordPress Work?

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:

<?php
get_header();
if (have_posts()) :
while (have_posts()) :
the_post();
the_content();
endwhile;
endif;
get_footer();
?>

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.

Comments

  1. Steve says

    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?

  2. Mike says

    WordPress is the most useless piece of shit I’ve ever seen. I signed up with GoDaddy to set up a blog and they told me to use WordPress. Well wordpress had no directions or help whatsoever. Needless to say I have cancelled my account with GoDaddy and advised them to disassociate themselves from WordPress.

    • Steve says

      Damn – I don’t mean to be crass, but you don’t have to be a rocket scientist to set up WordPress, just follow a few simple directions. There is a ton of help at http://wordpress.org on how to set the software up. There are even videos at http://wordpress.tv.

      I’m sure GoDaddy is going to take your advice to heart. 😀

Leave a Reply