Skip to content

Using WordPress As A CMS

I’ll let you into a little secret. WordPress is a CMS. Arguably it’s a simple one, but it’s still a CMS; I’m currently writing my content and using WordPress as a system to manage my content. WordPress needn’t just manage content for my blog though. With pages and page templates you’ve got a quick and easy way of making a killer content management system.

In this post we’ll look at how to understand just how to use WordPress “as a CMS” effectively and efficiently.

Understanding posts and pages

This is key. Once you’ve got this it’s easy to understand how you can build more complex sites quickly. Posts are for blog posts, pages are for “static content”, something else I’ve never understood; just because it’s on a page doesn’t mean it can’t be dynamic; that’s what makes WordPress such a fantastic CMS: you make “static” pages and then fetch other bits of your content dynamically.

Essentially, posts are for blog posts and pages are for everything else.

Creating ‘dynamic’ ‘static’ pages

WordPress’ pages support things called page templates which are essentially special templates or designs which you can apply to each page. These make your ‘static’ pages ‘dynamic’ as you can then use the loop amongst other things to fetch your posts, perhaps using custom fields to get only the specific info you need.

Creating a page template is easy: just add

<?php /* Page Template: Name */ ?>

to the top of your file and it’ll be available immediately as a page template once you’ve uploaded the file into your theme’s folder. You’ll find these on the page editor page, by default on the right hand side. Choose it and save and your page will immediately have the specific page template, not the page.php file which pages have if there’s no page template set.

As I said earlier, your pages can have dynamic content, specifically anything that can run in a normal template file. That means loops (via a custom query) which you can then use to grab content off your posts (like custom fields), but we’ll come to that in a sec. First the custom loop:

<?php
    $customQuery = new WP_Query();
    $customQuery->query('posts_per_page=5');
?>
<?php while ($customQuery->have_posts()) : $customQuery->the_post(); ?>

<!-- Do query stuff here -->

<?php endwhile; ?>

This is just a simple loop that gets the five most recent posts, but you’ve got all the power of the loop at your disposal so can use any of the parameters to perhaps get posts with the custom field “show-on-page” by replacing posts_per_page=5 with meta_key=show-on-page. You can learn about the basics of WordPress theme design here.

Real-life application

We’ve now got a hypothetical shop and want staff to be able to add to a page the latest offers. Each offer is a post but we only want one line of text briefly describing the offer. We’ve built a custom meta box to allow an easy way of adding custom fields to posts. The custom field contains information about our latest offers.

We want to use a custom page template, custom loop and custom field in order to display a little section about the latest offers. We also want to show “no offers at the moment, check back later!” if there aren’t any offers set. Here we’re combining everything, with a little custom fields added in extra.

The full code could look something like this (of course this is in a custom page template!):

<?php
    $customQuery = new WP_Query();
    $customQuery->query('meta_key=show-on-page');
?>
<?php while ($customQuery->have_posts()) : $customQuery->the_post(); ?>

<?php $offer = get_post_meta($post->ID, 'show-on-page', true);
if ($offer) {
?>

<p class="offer"><?php echo $offer; ?></p>
<?php } else { ?>
<p id="no-offer">Sorry! No offers on at the moment, check back later!</p>
<?php } ?>

<?php endwhile; ?>

And that’s it. Hopefully now you’ll understand exactly how you can use WordPress to power just about everything! There’s really nothing complicated about making everything easier to use! Do share if you’ve got an ingenious application for this.

Image by Wordle.

Yay! 🎉 You made it to the end of the article!
Alex Denning
Share:

20 Comments
Most Voted
Newest Oldest
Inline Feedbacks
View all comments
Danny Walker
February 6, 2012 12:55 pm

The great about WordPress is the user base, And the way one easily can make plugins for it, and with allot already available. I’m currently using it for a remake of an old non WordPress site, this site will be quite advance, with allot of pages round 5000+ when finished, we’ll see how it will hold up on this scale.

Shilpa
June 17, 2011 5:37 am

Hello,

Very good article and its helpful to understand WP.

I recently migrated to WP from blogger and trying to find a way to make my pages dynamic as I am writing novel.

But unfortunately WP pages are static unlike the home page which gives option to move between older and newer posts from the post I am reading in. Any idea how I can incorporate the same for my pages..

Would appreciate your kind help!!

Brett Widmann
October 27, 2010 11:48 pm

Thanks for info and code!

How To Create “Dynamics Statics” Pages | Unlock IMEI Cellphones
June 14, 2010 1:03 am

[…] On our current example, on each post that we want play as page, we only need to added custom field this-is-page. If you need real example for this tricks you check it on WP Shout. […]

Bart Hook
June 3, 2010 1:54 am

Found a nice little snippet of code today that I thought I would share. It allows you to put a specific post on any page or in any template.


array(47),
'post_type' => 'post',
'post_status' => 'publish',
'posts_per_page' => 1,
'caller_get_posts'=> 1
);
$my_query = null;
$my_query = new WP_Query($args);
if( $my_query->have_posts() ) {
while ($my_query->have_posts()) : $my_query->the_post(); ?>
<a href="" rel="bookmark" title="Permanent Link to ">

James Macfie
May 31, 2010 10:53 am

I couldn’t agree more – I love WordPress for it’s simplicity and scalability. And 3.0 with it’s custom pages it going to make things a lot more interesting. Excellent article

Ross Sclafani
May 30, 2010 8:01 pm

I have been putting a lot of work into this direction.
I built my site in actionscript 3 using a framework i’ve mad called WPMVC. it utilizes the page template property to map something like “article.php” (which is a wp page template i added to my theme) to a class called Article that extends Sprite. All of these template classes have internal logic for parsing the page’s content and displaying it in my Flash movie. Other templates i have, like one called “RowGroup” actually parses and displays the contents of the templated page’s child pages. Check out my site to see what WPMVC looks like on my site, then disable Flash or visit with an iPad to see the underlying WordPress site. the non-flash theme is a generic one i created called FlashFrontEnd which handles the embedding code, but is currently ugly and doesnt really display the content correctly without flash, but you can see the potential to have a multi-multi-platform Site running off of WordPress.

Bart Hook
May 30, 2010 3:51 pm

WordPress is a very powerful CMS. I have been using it for my freelance clients for years. Recently I was able to convince my employer of it’s capabilities.

Bart

Using WordPress “As A CMS” | Wordpress | developingElegance();
May 18, 2010 4:32 pm

[…] Using WordPress “As A CMS” [WPShout] […]

Bram Van Oost
May 10, 2010 6:57 pm

The next WordPress release will lean more towards the CMS, and less to the blog, making content types possible (for example ‘movies’, ‘actors’, ‘books, ‘authors’) than only a ‘post’ or ‘page.

Looking forward to this very much!

Best On WordPress From The Past Week N.5 » wpCanyon
May 10, 2010 3:55 pm

[…] USING WORDPRESS “AS A CMS” […]

Rilwis
May 8, 2010 8:06 am

In this post, I love the ‘dynamic static page’ term :). It’s amazing feature of WordPress, that helps us very much to create custom page template. Using only this feature, WP has already ability of a basic CMS like some other open sources software.

Andy Kinsey
May 6, 2010 9:34 am

This is a nice post, but lets be honest there is not much too hard about making WP into a CMS … you just need a little confidence in how you do things and of course the odd site like this 😉

iris
May 6, 2010 7:33 am

Great article, thanks!
I’m even using WordPress to manage Flash-sites. Works like a charm.

Randy
May 4, 2010 3:26 am

I could not agree more! I have made many custom wordpress sites and only a small handful were actual blogs!

When you think about it,most any type of organization or business probably needs a recent news or events section. That alone makes WP so handy for more than just “managing” some text or images.

I cannot see a reason to ever push a client to have a static website when WordPress does so much out of the box.

I think that most people don’t realize that a WordPress home page, or entire website, can look and do anything they want it to. They also don’t realize what the power of RSS means but they will soon!

Angie Bowen
May 3, 2010 9:47 pm

Very interesting and a great example to act as a jumping off point. I’d be interested in more posts on using WordPress as a CMS with more specific examples.

Or start the conversation in our Facebook group for WordPress professionals. Find answers, share tips, and get help from other WordPress experts. Join now (it’s free)!