Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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:

  1. Wordpress is not set up to easily replicate a classic CMS, particularly with regard to having several pieces of content on one page.
  2. This model can be imitated, more or less, using custom posts (see below)
  3. 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:

  1. The page is a 'Page' with a custom template - call it 'mypage.php'
  2. 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? :-)

share|improve this question

migrated from webmasters.stackexchange.com Jul 25 '12 at 7:26

This question came from our site for pro webmasters.

    
Wordpress questions are perfectly fine here, unless they delve too much into programming. –  Tim Post Aug 3 '10 at 11:57

5 Answers 5

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.

share|improve this answer
    
I'll have a look into custom post types. The problem with custom fields, if I understand them correctly, is that, at worst, they're just plain text, and at best, they don't offer WYSIWYG editing. –  Bobby Jack Aug 4 '10 at 10:44
    
It would also be wise to make sure you're familiar with custom taxonomies, and how they work with custom post types. –  tnorthcutt Aug 4 '10 at 16:21

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.

share|improve this answer
    
Hmm... I'll take a look at the links, but I'm not entirely sure I've explained myself properly. Essentially, I need to work with the most 'atomic' piece of content possible; something that every other CMS I've used makes very easy. I've updated the question in an attempt to explain it better. –  Bobby Jack Aug 3 '10 at 13:03
    
If you want the content to be static (and by static I mean plain HTML not served from a DB - like the wordpress posts) but you still want to modify it, then add the chunks to the template. Otherwise put it in a page and that's it. –  Alex Aug 3 '10 at 14:02
    
and if I want those chunks to be WYSIWYG-editable? –  Bobby Jack Aug 4 '10 at 14:12

I think your best bet is to use custom post types.

share|improve this answer

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.

share|improve this answer

The best plugin for painlessly adding custom content areas beyond just title and content is probably the "More Fields" plugin.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.