I’ve only ever used wordpress as a self-hosted blogging platform – until now. I have a requirement to use it for a very basic CMS which will consist of ~ 10 pages, most of which will be static content, updated periodically. I’m going to need to ability to upload documents, embed images, edit copy using the text editor – pretty much all of the standard features wordpress offers.
However, I’m having difficulty surrounding the issue of editing specific sections within a page – in particular, just knowing where to begin. A ‘normal’ CMS would traditionally break a page into separate sections and allow me to edit any of those sections, either by directly editing the content, or by including shared content in that spot. I cannot find out how to do this using wordpress.
Is it possible to ‘stretch’ the Page model so that a Page is actually just a chunk of content, it gets included by a specific page/template, and it’s – somehow – protected from being viewed directly (removing it from navigation menus being a start).
Any pointers on where to begin?
Update
To clarify, imagine a standard wordpress blog post. Pretend it’s a static piece of content. Suppose you wanted an editor to be able to change just the first paragraph of that blog post. Now,
- should the static content on that page be in a Post, Page, Template, or something else?
- should the editable content be a Page, … or something else?
For example:
<h1>About us</h1>
<p>Example.com is a company specialising in examples, demonstrations,
and canonical stuff.</p>
If I want that paragraph to be editable, presumably I need something like:
<h1>About us</h1>
<p><?php insert_page('name-of-content-chunk'); ?></p>
Update 2
OK, after a lot of research, trial, and error, I’ve included the following:
- WordPress is not set up to easily replicate a classic CMS, particularly with regard to having several pieces of content on one page.
- This model can be imitated, more or less, using custom posts (see below)
- Pages very nearly offer the ability to do this, however:
- A plugin is required just to include a page
- Pages don’t seem to be as flexible as posts – e.g. no custom page types
The method I’ve used, using custom post types, is broadly as follows:
- The page is a ‘Page’ with a custom template – call it ‘mypage.php’
- That template contains the following:
<div id="header"> <?php query_posts(array('name' => 'foo', 'post_type' => 'header-text')); get_template_part('header-text'); ?> </div> <div id="content"> <p>Some static copy in the template that can only be changed by the site administrator.</p> <?php query_posts(array('name' => 'bar', 'post_type' => 'image')); get_template_part('image'); ?> </div>
Does that make sense to anyone out there? 🙂
As tnorthcutt mentioned, you may want to use custom post types. However, you should also take a look at custom fields, which will allow you to specify bits of dynamic custom data that you want to associate with each page. Here’s Smashing Magazine’s tutorial on custom fields, Nettuts’ tuturial (and video), and a list of other tutorials.
If I understood correctly, you want to have different layouts for different pages. You can achieve this either by having a custom template for each page of the site or by having a single custom page, with various conditions.
For the first option, see the WordPress Codex section regarding custom template pages: http://codex.wordpress.org/Pages#Creating_Your_Own_Page_Templates
For the second one, see this tutorial: http://www.darrenhoyt.com/2007/12/26/multiple-wordpress-page-layouts-in-one-single-template/
Then, you can move these “chunks” into different PHP files that you include in your specific pages.
I think your best bet is to use custom post types.
Have a look at a plugin such as Magic Fields. It uses Custom Fields internally, but the interface can have rich text editor, list drop down, etc.
This allows you to define your content elements, their types and (for choices) their values. Then, your theme can display it.
An alternative, would be to have a plugin area defined and decide what plugin would go in there. That’s less flexible though, as it still does not allow for two page/post specific content pieces.
The best plugin for painlessly adding custom content areas beyond just title and content is probably the “More Fields” plugin.