skip to content rich footer

stevenclark.com.au

subscibe to the StevenClark.com.au rss feed

WordPress: Page Within a Page

One of the limiting factors I see within many wordpress designs is the tendency to remain blog-like even though a site might require a different look and feel to the standard two column generic layout supplied by the default template. Merely changing a header image and filling in some basic colour changes doesn’t make a solid customisation. You can, in fact, make WordPress look exactly like you want with a few customisations of the templates themselves. If you can draw it you can most likely build it - something worth considering.

To that end I suggest you may find use for the following code snippet which allows you to call the content of any authored page on your WordPress site into a sup-part of another page - perhaps index.php could do with some static content.

<?php global $wpdb;
$pages = $wpdb->get_results ("SELECT post_content FROM " . $wpdb->posts . " WHERE ID = 15");
foreach ($pages as $page)
{
echo $page->post_content;
} ?>

So why would you do this? Well I’ve found great use with clients who I only want to allow editing of a certain section of a page. For example, a portion where they offer a weekly special. I don’t want them playing in the code (no way) and I don’t want them going to a full page with other information they might inadvertently junk up on me. So I’ll jump into the template and call this snippet where the ID equals the page that contains the content your client can edit. Its that simple really. The client is given the name of that specific page (in this case it is called specials) and they just open that one page when they need to update specials on their site.

You should note that creating your new page will add it into your pages navigation list called by the wp-list-pages() function. You’ll probably want to exclude it with a parameter of &exclude=15 where the number is that of your specials page.

Comments are closed.

Stand Up Guy

Steven Clark Steven Clark - the stand up guy on this site

An icon for overweight middle aged bogun-geek web designers. A lego block in a Meccano world. A synergy of tattoos, memories of bare knuckle fist fights, and old episodes of Star Trek. My name is Steven Clark and I'm a highly opinionated web designer with a few good ideas. I'm too old for fist fights.

My Photography Blog

My photography blog Walk a Mile in my Shoes is back up and running. Due to bandwidth issues it's only one image at a time and not full text in the RSS feed. It's licensed under creative commons , meaning not for commercial use and you need to attribute, otherwise drop me a line via the contact form on this site.

My Links Blog

You might also like to check out my links blog over at Nortypig.com to learn more about everything worth mentioning.

My Illustrations

Currently I only have a static page for illustrations but if time allows I'd like to start another illustration blog.

Declaration of Independence

Site Content

Developed and published by Steven Clark

Site Supporters

Hosted by Brett at Tashosting

skip to top of page

Currently Reading

Here Comes Everybody by Clay Shirky (cover)

Clay Shirky's Here Comes Everybody: The Power of Organizing without Organizations has been on my bookshelf for the last few months literally screaming to be read. In fact, I'm wondering how I got so sidetracked to have reached the end of the year without having consumed it. The message of the book is an area of my own fascination, the effects that our new technologies have on the way we relate to each other, and how we're now empowered in ways that were historically unheard of (or not even conceived of) not too long ago.

I'm a small town boy who grew up in the seventies, graduating high school in 1979. The world was slower - how did we survive without Wikipedia? Without MSN or Facebook? Nowdays we have flashmobbing and blogging and constant connection.