How to use WordPress as a CMS

Template editing

Most default WordPress templates have space for page navigation already in the sidebar, alongside other default elements. If you want to use WordPress as a CMS rather than a blog, you may want to pare down the code so it only displays your page hierarchy. To do this, go to Design in your Dashboard and choose Theme Editor. This gives you direct access to the component elements of your page layout – which is parcelled out into separate PHP files. Choose Sidebar for a plain text view of the file sidebar.php. Navigation elements are listed in the form:

Recent Blog Posts


In this case, the line of PHP listed pulls a recent list of blog posts (the number is determined elsewhere in the Settings | Reading section of your Dashboard). The PHP data repeats using the HTML encapsulating it until the end of the data or limit of the command. To remove all blog elements, you simply delete all PHP references to blog posts, including the HTML mark-up around them. In the case above, everything from

You can also hard code links in the body of the code. For example, although you've removed blog navigation above, you could have an HTML link to a blog entry page within your site. This enables you to have a static appearing site, with a single blog link in the same hierarchy as your fixed pages. Here's the code we use:

Site Map



My Blog

Here, the line of PHP code generates a formatted list of WordPress pages – which could be the usual About Us, Portfolio, Contacts structure common to small business and personal sites. Then the hard-coded hyperlink 'My Blog' points to a page that lists recent blog entries. Using an asterisk instead of a post number passes a wildcard to WordPress, coaxing it to generate a page chock full of recent entries.

Front page control

So far, so subversive. But, when you install WordPress the software still automatically displays the first blog entry in its database when you go to the front page – not a static page of your choosing. Not many people realise that you can actually change this behaviour, bypassing the blog element of WordPress for the time being. In the Dashboard, go to Settings | Reading. In the first section labelled Front page displays, change the setting from the default 'Your latest posts' to 'A static page'. Choose any page from the drop-down list and, hey presto, your blog is now a CMS-driven dynamic website.

Beyond the standard functions WordPress offers modular plug-ins that help to make it behave even more like a CMS. If you go to the Plug-ins section in the WordPress admin panel, you'll find a couple of useful add-ons ready to install. Akismet is a spam catcher for your comments section, preventing known blog spammers from posting – and we strongly advise that you put it to work straightaway.

To start using the plug-in, click 'Activate' – this physically installs the code into your database. To activate the plug-in fully, you'll need to sign up for a WordPress account. To create an account go to www.wordpress.com. Once the process is complete, return to your site's WordPress admin section and click on 'Akismet Configuration'. Right-click on the link prompting you to grab an API key and choose Open in New Tab from your browser's context sensitive menu. If you're logged into WordPress.com, you'll be taken to the My Account page, displaying a 12-digit serial number. Highlight and copy it, then tab back to the Akismet Configuration page, where you can now paste in your API key.

The fully configured plug-in will now prevent known spammers from cluttering up your comments section with their ads for Viagra and get-rich-quick schemes. You'll see how many it captures in the Aksimet Spam section on your Comments page.

Adding further plug-ins is easy – download the associated files from the plug-in's website and upload it to the 'wp-content/ plugins' folder in your remote WordPress installation. They'll appear, ready for activation, in the Plug-ins section of the WordPress dashboard.

-------------------------------------------------------------------------------------------------------

First published in PC Plus, Issue 278

Now read 11 WordPress plug-ins every blogger needs

Sign up for the free weekly TechRadar newsletter
Get tech news delivered straight to your inbox. Register for the free TechRadar newsletter and stay on top of the week's biggest stories and product releases. Sign up at http://www.techradar.com/register

Follow TechRadar on Twitter