WordPress as a universal CMS

Posted by on May 5, 2012 in Blog, Web Development | No Comments

WordPress LogoWordPress has become the top open source CMS, not least of all because of its clean and simple back end.   More and more web content editors are asking developers to integrate WordPress managed content for display on other websites.  A company’s news page is a typical example.

A little more than a year ago we built the Take A Seat website;  WordPress was a natural fit.   The clients, René and Susan, were immediately comfortable with the WordPress back-end and were posting articles within hours.

René and Susan are design aficionadas  from The Modern Home Co (MHCO).  The company website had it’s own news section that Susan and René attempted to keep up to date via its custom and frustratingly limited back-end CMS.  Inevitably, the question:

Would it be possible to use  the Take A Seat website to feed the MHCO website’s news page?

The short answer:


The Solution

An Alternate Front Page for WordPress.

What is meant by this is that a) we want to display the latest posts in a specific category, b)we want to control the styling independently , and c) we don’t want any theme-specific  markup or content, like menus, sidebars, etc.  The solution was a small php script installed in the WordPress root folder:

/* mhco-news.php
 * Alternate front to the WordPress application. This script loads wp-load.php
 * and bypasses loading a theme.  Instead, it goes directly to reading posts.
 * Support info: denis-at-potion-dot-co-dot-za  http://www.potion.co.za
 * @package WordPress
 * @var bool
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>MHCO News</title>
<link rel="<a>stylesheet</a>" href="<a>/styles/news.css</a>" type="<a>text/css</a>" media="<a>screen</a>" />
define('WP_USE_THEMES', false);
query_posts('cat=39'); //IMPORTANT this is the MHCO News Catgory ID
while (have_posts()):
        <h2><?php the_title(); ?></h2>
        <p>Posted on <?php the_date();?>, <?php the_time(); ?> by <?php the_author(); ?></p>
        <p><?php the_content(); ?></p>
        <div><hr /></div><?php

An iframe to load the WordPress alternate front page.

To display the WordPress output on the MHCO website simply involved removing the php code that collected the content from the MHCO database and replacing it with a simple HTML iframe tag.

<div id="main-content" class="news"
   <iframe src="http://www.takeaseat.co.za/mhco-news.php"></iframe>

Controlling where posts should display

Possibilities for post display included: on Take A Seat only, on MHCO only, or both.   To control this we used the usual WordPress categories  in conjunction with the WP Hide Post plugin.  Now, using a combination of category assignment and post visibility we are able to control exactly where the post is displayed.