Blog

ProcessWire vs WordPress: it's the API


Why don't we just use WordPress?

When over 30% of all websites use WordPress, making it the number one CMS by popularity, clients may question why a website development company would be using some other CMS.

Suppose we have a website that holds information about books, and we want our website to find and list the title and author of books that were written in a certain language and published after a certain year, with language and year to be specified by the user.

In WordPress, the code would look like this:

$args = array(
  'post_type' => 'book',
  'meta_query' => array(
    'relation' => 'AND',
    array(
      'key' => 'language',
      'value' => $language,
      'compare' => '=',
    ),
    array(
      'key' => 'year',
      'value' => $year,
      'compare' => '>',
      'type' => 'numeric'
    )
  )
);
$query = new WP_Query($args);
while ($query->have_posts()) {
  $query->the_post();
  $title = get_post_meta(get_the_ID(), 'title', true);
  $author = get_post_meta(get_the_ID(), 'author', true);
  echo "<p>Title: $title</p>";
  echo "<p>Author: $author</p>";
}

And this is what we'd write to create exactly the same functionality using our favourite CMS, ProcessWire:

$books = $pages->find("template=book,language=$language,year>$year");
foreach ($books as $book) {
  echo "<p>Title: {$book->title}</p>";
  echo "<p>Author: {$book->author}</p>";
}

The example could be about selecting products in an e-commerce store, or photos from a portfolio.

As a rule of thumb, the more lines of code we have to write (and read) the greater the cost to our clients, and the greater the chance of error.

The ProcessWire code above is simpler, but the ProcessWire API is also more powerful. Simplicity and power go hand-in-hand.

Programmers love to talk about Application Programming Interfaces, or APIs for short, which refers to the means provided by a piece of software for interacting with it and getting it to do stuff. WordPress started life as a blogging platform and the Content Management System features which make it a general purpose tool for building websites were tacked on later, as a result we find its API to be awkward, time consuming, and lacking power. ProcessWire on the other hand was built as a CMS from the start and has an extremely well thought out API, which makes it a great choice for building bespoke websites.

This is not about hating on WordPress

Credit where it's due.

If you're strapped for cash and you want a website you can just take and run with, then buying a WordPress theme offers unbeatable value for money.

A theme is essentially a pre-fab website with some customisation options built in, allowing it to be sold not once but to thousands, or tens of thousands of buyers, who can then add their logo and choose a colour scheme and layout options. Economies of scale mean that developers can put a lot of work into developing a theme, sell it for ridiculously cheap prices, and still make a profit.

Coupled with a large selection of third party WordPress plugins for adding functionality, some commercial and some free or partly free, and you can get a whole lot of website for very little outlay.

Themes are where WordPress really shines, but this approach has drawbacks

Although professional in appearance, theme designs are somewhat basic and generic out of necessity. If you want a unique design and a strong visual identity, themes are not much use.

Theme-based websites are generally slow to load. This is partly due to the large number of CSS and JavaScript files used to provide theme customisability, and partly due to the use of impressive but computationally expensive visual effects to encourage theme sales. Speed matters, a lot.

WordPress has had many, many security issues. This is partly due to the popularity of the platform, making it an attractive target for hackers, perhaps partly due to insufficient focus on security, and partly (56% to be precise) due to extensive use of third party plugins, which creates a large attack surface for hackers to target. A typical website is subject to between tens and thousands of automated attacks per day, and around 90% of those are looking for WordPress installations.

Themes and plugins are designed for thousands of users, not for you. They may meet 90% of your needs, or 50%. If you have complex content requirements, it may be 20%. But it's rarely 100%.

Using plugins means relying on plugin authors to keep pace with WordPress development. Too often a WordPress update will break a plugin, giving you a choice between upgrading WordPress to keep it secure or not breaking part of your website's functionality. This can get really messy.

What if I want a bespoke design and functionality that meets 100% of my requirements?

This is where WordPress loses. Once you go bespoke the whole WordPress economy of scale disappears and you may end up paying more for less compared to using another CMS. The awkward, time consuming nature of the WordPress API doesn't matter if we're making a theme that will be sold ten thousand times. When we're making a bespoke website for one client, it matters a lot.

In conclusion

We see no advantages and many disadvantages in using WordPress when it comes to bespoke websites and complex content requirements, but we appreciate its value in providing options for individuals and small businesses on tight budgets.


By Spritely Design