When I first stumbled across WordPress (which I’m using to power my website), I was very pleasantly surprised by the excellent administration environment, and just how easy it was to setup and use. Before I even decided what tool I was going to use for my website, I had come up with a basic design and color scheme that I was going to use. I managed to stay pretty close to what I wanted, but there were several things that made it a bit trickier than expected.

In order to get my custom ‘skin’ for WordPress I needed to create a theme – this is pretty easy as a theme is really only composed of a few pages. The template tags used to create a theme are relatively straightforward and I was able to get something up and running very quickly. The difficulty is that the template tags are aimed at very novice users, which means that they hide a lot of complexity. And while hiding complexity is often great, it also means added complexity when you try to do something that is a little outside of the feature set.

For example, WordPress has a feature called ‘Pages’ where you can create regular posts that act more like static pages and aren’t blog-like. In addition to not sitting within the standard blog flow, pages can have child pages so you can build a hierarchy of pages. An example of ‘Pages’ on my site is the ‘About‘ page you can see linked on the left. If I wanted to I could write a sub-page called About Me with sub-pages for My Education, My Resume, and My Hobbies. Now I don’t really have anything on this page, so I guess I’m giving a bad example – but you’re smart, you can imagine it.

While it was possible to create a hierarchy of pages, the only place to show it was really in the navigation bar on the left. Obviously this isn’t acceptable if you have several levels of nesting – the left column isn’t big enough. You can limit the ‘depth’ of the tree, but then the lower levels aren’t shown anywhere, and a page that no one can get to just isn’t too useful. I wanted two additional things:

  1. To show a breadcrumb under the page name which would have links to all of the parent pages
  2. To show a list of child pages

I understand that Pages were only introduced in the current release of WordPress, but these seem like two very obvious requests. The unfortunate thing with doing these is that the API provided by WordPress is so targetted at its own templating that it requires a developer to talk directly to the database to get data. Most of the template tags return data with HTML embedded, so if you want to use the data for another purpose they become useless. Using the WordPress plugin functionality I was able to write a class which augmented the standard Pages feature set with some useful functions.

I understand that the template functions return HTML to simplify things for the user, but it would be great if there were some lower-level functions which returned information as data (i.e. returning an array of child pages) so that the user can choose what to do with them. So while it might be easier to write:

1
get_child_pages($id)

I would personally rather write:

1
2
3
4
$children = $page->getChildren();
foreach ($children as $child) {
      //  do something
}

I think that this actually ends up being more readable because it’s not as spooky – you can see exactly how the data is being rendered on the page, and if you need to make a change to it you can do it write on the template instead of changing the source code of the API.

But….overall I’m very happy with using WordPress and how flexible the system is. I wish the team continued success with the project!