While building a web site, it is sometimes important to manage content pieces separately and independent of each other. Imagine a corporate site with a homepage that has briefs on its various offerings, and a brief about itself. Each of these briefs are managed independently, and the homepage is composed by integrating them together. How do we achieve this with WordPress?
One of the ways this can be done is to include the text in the theme file itself. But this means that you will have to ask the maintainer to modify the theme file to modify the content, which can be dangerous. Also, as a CMS developer, I would like the administrator to get a first hand way of managing this content, including a WYSIWYG editor if they are used to it. The first thought that came to my mind was to write a plugin, which I still think is the best solution to work with. However, I experimented with something else as well - using private pages to do this.
We can use a page for every piece of content we want to be managed independently. The only problem is that these pages are still visible to the WordPress loop. One way to avoid this is to make them private. We can then use the get_page function to retrieve content from one of the private pages, which takes the page ID and returns the page to you. Or we can use get_page_by_title where we can pass the page title to retrieve the page.
This will provide all the WordPress editing tools to the content editor/maintainer to modify these individual pieces of content. It will also give them a good admin backend to manage those pages themselves.
Having said that, there are certain disadvantages of this approach. Retrieving multiple pages to compose one page means more database hits. Secondly, by making the pages private, and hidden from the WordPress loop, we will not be able to use any of its utility functions, like the_content. We will have to use $page->post_content to retrieve the page content in our template. Though this is not difficult, functions other than the template tags can change in future releses.
A plugin might be the real solution here, though using the pages differently was quite interesting, and might turn out to be useful in some cases. What do you think?



December 27th, 2008 at 2:19 am
You are onto something here. Many people misuse Pages in WordPress, often for the very reasons you list. Working with private Pages is messy, though, so I think a Plugin that is a work around would be brilliant, and help a lot of people understand and use Pages more efficiently. I know I would.
December 27th, 2008 at 3:47 am
Interesting approach. Still I think the plugin approach might be less troublesome. Check out WP-Components plugin. Should do what you need once you add the proper tag to the theme.
January 5th, 2009 at 4:38 pm
I think that’s still a downside for Wordpress. For small pieces of text we have to instruct client to update templates, not very elegant and/or safe .
On a past project it was a must to administrate some static texts from control panel and because i couldn’t find nothing similar,
I’ve made a simple plugin : http://github.com/vio/wp-blocks/tree/master .
Regards.
April 10th, 2009 at 10:52 pm
This is a great solution to a WordPress problem I am having for a client. Of course, I made sure to subscribe to your feed on Google Reader immediately and hopefully, you’ll keep writing great posts just like this one.
Thanks for all you help in the community–and that community is exactly why I can’t recommend another CMS over WordPress.