Semi-Static WordPress Homepage
Written by Zain on September 12th, 2007{ 11 comments }
I’m a great fan of Lorelle. She writes some really interesting stuff about WordPress and Blogging and you should all check out her stuff.
Recently (well, last week - but I’m slow at getting round to things as I’m quite busy), she posted up an interesting “challenge” to “help kick [our collective] blogging ass” as she puts it.
Well, I thought I’d share with you all a tip on something that I’ve recently been working on. I’m quite pleased with the result even though the solution isn’t the most ideal and rather raw. It isn’t the most elegant solution as I’d have hoped it to be but it works…
This isn’t specifically a “blogging” tip - it’s more of a theme tip. Or rather a way in which you can push the boundaries of WordPress if you’re inclined to think of WordPress as something other than “a blogging tool”.
And I do.
Now, I know some of you WordPress and Blogging purists are going to hate me. But hey, screw that - WordPress is Open Source and the whole point of Open Source projects is that you can push them to become what you need them to do. Right?
I’m not about to get into a debate on the whole purity of the blog thing right now. Instead, I’m going to show you what’s possible if you put your mind to it.
As you may have gathered, I’m taking up Lorelle’s tips challenge on this one and this post is about creating a Semi-Static WordPress Homepage.
Are you ready? Are you confused? Read on and I’ll explain everything.
I’m not going to lie to you - this isn’t easy but it’s worthwhile making the effort and following the steps if you want to make your site *ROCK*. BTW, I originally posted this tip on the StomperNet forums but thought it was good enough to share with you all as it is pretty cool and “I do what I like and like what I do” (hmmm… I’m sure there’s a song there somewhere…).
Okay - so, let’s get the party going… The question is:
“How Do You Create A Semi-Static Homepage?”
Firstly, let’s consider another question:
“WTF would you want to do that anyway?!?!?”
Good question. I like your train of thought. Destination unknown - so let’s get it back on track, shall we?
There’s a couple of good reasons.
Firstly, I’m currently working with a couple of clients who like the idea of displaying some information about themselves or their sites on the Hompage of their WordPress blog. At the same time, they like the idea of having the most recent posts showing up *in the main body* of the page too.
Note here: The key here is “in the main body of the page” and *NOT* in your sidebars. This is important as we’ll see in a minute.
B) Because having a partly static or semi-dyamic home page is such a cool idea. Why wouldn’t you want one?
And on the other hand) the idea is right out there on the edge of a reasonable wishlist items and these types of challenges make working with WordPress interesting. I love tackling something like this and pushing the boundaries of WordPress! Might as well enjoy what you do, eh?
So, some of you may have already upgraded to WP2.1+ and found a new feature called “Static Homepage”. It’s pretty cool - you can select a Page to become your homepage and use the selected page to display a whole manner of things.
What’s The Problem With Static Homepages?
Well, to be frank, I’m using version 2.2.1 and finding this very buggy. There’s hardly any documentation on this new feature although I found this interesting article on how to create a static homepage on Richard and Stephanie Sipe’s blog and, while it shows you how to can select Static pages for the Front Page (home) and Posts Page, personally I don’t think it goes far enough.
How far is far enough? For me, that would be a “Semi-Static” homepage. Plenty far enough without falling off the edge.
Let’s look at the “Front Page Displays / A Static Page” feature in WordPress. You can find this under Options / Reading in WP2.1+.
Here’s a few problems:
- In the section called “Front Page Displays”, selecting a Static home “Page” means you cannot add The Loop to the page to display Posts. The Loop will simply display Pages found and not Posts - not sure why this is.
To be honest, I don’t care - it doesn’t work at the moment and I’ve spent too much time faffing about with trying to get it to work… I even manged to get it to sort-of work with pulling in Posts but you know what? The friggin’ More links didn’t work and the entire Posts got rendered to the screen.
Even if you try to use Scott Reilly’s Customizable Post Listings plugin, you’ll find that Pages get pulled back by The Loop when you set the this feature to use a Front Page with a default template. I’ve fiddled with it and can’t seem to bring back the most recent Posts in a *reasonable* fashion.
- Selecting a Static “Posts Page” to be your Front Page display is equivalent to using your index.php file (or just leaving this option set to “Your latest Posts”!). WTF? Maybe I’m missing something here. Some documentation on this would be great! Doesn’t even seem to consider stuff out of The Loop when rendering…
- Setting both the Front Page & the Posts Page to be the same thing - Well… it says you shouldn’t do this… heh heh. I love doing this. I’d recommend you give it a go and see how exquisitely WordPress messes this up! Heh. Just select both things to be the same options and *BLAM* - major accident waiting to happen… hehe…
Okay, so maybe it might be because of the lack of documentation here. I’ll admit, maybe I’m missing something and perhaps someone might have a more elegant solution to this. Now, many of my ex-work colleagues know that I wasn’t particularly the best coder - I’ll admit that (which is why I went over to the “Dark Side” and became a Project Manager
). However, I do try things out loads; spend several hours looking things up to see if anyone’s got a sensible solution; get frustrated when I can’t find anything and then just do things in my own way…
The point is, I’ve got a solution. It works. I’m happy with it. Until someone else comes up with something better, then I’m sticking to it. Suggestions extremely appreciated on this one! (I dare you, I double dare you..!)
Anyway… are you ready for a “Semi-Static” homepage? Part static content with part dynamic posts? Or is that Semi-Dynamic with Partially Static content… who knows?
Ready to create some semi-static content?
Got your themes at the ready?
Sure?
Well… I’m not :P. Let’s have a look at it in action first to see what we’re trying to achieve before we begin!
Right, first off - go to this newly created site that I’ve recently worked on about Meta-Medicine: http://www.metamedicine.se/ and have a good look at the homepage.
Let’s stop a minute and have a good, hard, look at the homepage. Anything strike you about it? Probably not…
There’s a couple of points to note on this site. Firstly, yes, it is in actuality a Blog. It doesn’t look like one but, like I say, I like to push the boundaries. Sod that “my blog should look like a blog” crap - I know CSS and I’m using it! And using it *WELL*. Here’s two fingers up at mediocrity… if you want that, go elsewhere. And if you’re on an old browser (like IE5.5… shoot yourself. Really. Do. Evolve or die…)
As usual, I digress…
If you notice, we’ve got a nice section on the top introducing the site with a “Related Posts” underneath. At the moment (as the site has literally only just gone live) we have a recent post with a nice “More” link, right? (Note: this is important - using a Static Page as the Front page will never get you that nice “more” link). Well, that top section is in reality static text. It will continue to display the same thing and never change until it’s updated. The bottom portion with the “Related Posts” underneath *will* change. It’s set to display 5 posts.
Do you realise how long it took me to work this out? Several hours worth of research into the limits of WordPress. I’ve been pulling my hair out over this one.. and trust me, with a shaved head, that’s some serious pulling! But now I can reveal to you, dear reader, a way of achieving this cool feature as used on the Meta-Medicine site.
I’ll tell you now, it’s not a particularly elegant solution but does the job! It’s not what I’d recommend - in fact, I’ve ideas of how it can be done. But that’ll be the subject of another plugin…*cough* er… post. Did I say plugin? Ignore me…
So… how is this wonderful effect achieved?
Simply.
If you read my previous posts, then you’ll probably already know about the Sniplet’s plugin by John Godley from Urban Giraffe. Now that’s a*BIG* clue.
Here’s a step by step guide. This assumes you have a little knowledge of HTML and PHP.
The assumption I’m making about WordPress and PHP and *YOU* here is: FOR CHRIST’S SAKE, DON’T TOUCH THE FREAKIN’ PHP TAGS! (many apologies for my coarse language to those of you who are worshippers of PHP).
Got it? Good.
As always, I would recommend you back-up your theme; backup your site; get household *and* personal insurance and cover yourself, family and extended family before attempting to do any of this. Copy and paste any file you will work on into a notepad file and save it off! (It’s for your own good. And you know it!).
So… here we go:
- Download the Sniplets plugin from Urban Giraffe.
- Log into your Admin area and install and activate it as a plugin in your WordPress site.
- Click on the Manage tab.
- Click on the Sniplets tab.
- Add a new Sniplet by adding a name (call it “homepage” - it is important to make a note of it’s name whatever you call it!).
- Add the contents of whatever you want to have as Static content on your homepage to the “contents” area.
- Click on the “Add Sniplet” button.And you’re done creating a sniplet!Now onto creating the homepage…The following section can either be done in your favourite editor if you like to edit your WP php files manually, or by using the method described below (using the Theme Editor).
- Click on the Presentation tab.
- Click on the Theme Editor tab.
- On the right hand side, find your “index.php” file. (In Kubrick, this is listed as “Main Index Template” - this may vary depending on the theme you’ve got installed).
- Insert the following code into your template *where you need it*.
Note: On the Kubrick theme I put this just under the opening div tag containing the “narrowcolumn” class.
<?php
if(is_home() && function_exists(’the_sniplet’)){
the_sniplet(’homepage’);
}
?> - Hit the “Update” button.
- And that’s it! All done.
Explaining the Sniplet code
The is_home() says to WordPress that this should only be displayed on the homepage.
The && means “AND the next bit must be true as well“.
function_exists(’the_sniplet’) says to WordPress: “hey guys.. does anyone know about Sniplets around here?” and if WordPress has heard of “the_sniplet” then the_sniplet(’homepage’); function gets called to say that it’s needed on the homepage.
the_sniplet(’homepage’); then checks if it knows anything about the “homepage”. Since we’ve created a sniplet called “homepage” we’re in luck and it gets displayed on the screen.
The little function_exists function is also good because even if you switch off Sniplets, you won’t get that nasty error appearing all over your theme.
So what now?
Well, hopefully that’s 1) useful to you and 2) made you think about other ways in which you can utilise plugins to do different things on your site.
If you find a better solution to this “semi-static homepage” problem or even try this technique out for yourself on your own WordPress blog, then it would be great to know how you get on with it.
Let me know how you get on!
Tags: blogs, dynamic, help, home, homepage, page, partially dynamic, partially static, plugin, plugins, semi-dynamic, semi-static, static, StomperNet, WordPress, wordpress templates, wordpress theme










September 13th, 2007 at 12:19 am
Wow! Well! Speechless! Quite the tip. And thanks for the kind words.
Just to clarify, the Sniplet WordPress Plugin allows you to add static text to the front page of your blog rather than typing it into the template file in a conditional tag.
Neat idea and great tip. Thank you!
September 13th, 2007 at 9:22 am
Hi Lorelle,
The kind words are there because I regard you as being one of the best resources in the WordPress field. As a subscriber to your feed, there’s always quality information that I enjoy reading and think there are tips that other readers would do well to make note of. Always inspiring - keep it up!
Checking the comments today, I was glad that I left you speechless - I must be doing something *right*
. It’s just one of the few tips I’ll be sharing over the coming weeks on how to make full use of WordPress to make it do things that people wouldn’t normally expect.
I love pushing the boundaries.
Just to clarify (and I know you’re a smart cookie to have worked it out) - yes, all you need to do to change the static content is to go into Manage / Sniplets / Whatever-you-called-the-sniplet and then update the content. That will change the text on the homepage.
The beauty of this tip is that Sniplets also accept HTML tags - so your creativity and talent are the only things that will restrict you when coming up with a really amazing homepage. Add some tables, pictures or (for those of you in the Internet Marketing field) put your best products on the homepage!
Go for it and let us know what you’ve come up with! I’d love to see how far people take this tip.
Let’s start beautifying the web. Blogs don’t have to look like blogs!
Good luck.
October 3rd, 2007 at 4:27 pm
I;m setting up a new blog and your article was exactly what I was looking for on static pages. Thanks so much! You won’t have to read much further to guess i am green green green.
I have a couple of questions:
When i named the snippet homepage it showed up on the page just like that homepage and ugly.
My original homepage was the Freedom Train Depot. So I went back and took “home” off the page slug since I had designated it as that in my -options, reading pane in wordpress. and renamed the slug on “homepage”. Now my snippet doesnt show up anywhere now.
Also nothing will show up when i use the content tag - only shows up when i put it above posts on first page.
So one: how do i get my original title (Depot) to act as my homepage in your scenario? And second, why won’t anything i write show up if i tag it content?
Thanks so much.
October 3rd, 2007 at 9:13 pm
Hi Carol,
I’m a bit confused on precisely where you’re stuck. That’s probably because my instructions weren’t as exact as they could be.
Anyway, look out for an email as I’ll contact you directly on this to see if we can get your Semi-Static homepage working properly on your site. So far, I’ve installed it on 2 sites and working on a 3rd - it’ll be good seeing it working on another site too!
Cheers,
Zain
October 19th, 2007 at 5:36 am
How do you feel this will work with SEO’s?
Nick
November 18th, 2007 at 11:45 am
Something is wrong with http://www.metamedicine.se, because above the actual webpage I see a lot of blah blah like:
[16-Nov-2007 17:06:16] PHP Fatal error: Class filter_is_numeric: Cannot inherit from undefined class fi_filter in /home/metam7/public_html/wp-content/plugins/filled-in/extensions/filters/is_numeric.php on line 16 [16-Nov-2007 17:07:04] PHP Fatal error: Class filter_word_count: Cannot inherit from undefined class fi_filter in…. etcetera.
November 29th, 2007 at 3:02 am
Hi - thanks for this tutorial. Sadly I can’t get it to work.
This shouldn’t be a surprise though – I’m a complete beginner with Wordpress, and not much better with PHP, so this is bound to be a stupid question…
Anyway, nothing is showing up - nothing at all. If I manually paste my “static” text into my index.php file I get the desired result, so why not just do that?
November 29th, 2007 at 8:59 am
Hi Will,
Yes - you’re right this was spotted a while back and I updated the information in a later post. Another “newbie” (Carol) mentioned this and working with her on getting this working I updated the information which you can now find here:
http://knowledgeconstructs.com/semi-static-wordpress-homepages-yogi-ive-found-a-boo-boo
As for why you’d want to do this instead of adding text directly to your index.php, page.php or single.php - the main reason is “ease of use”. Once it’s set up, there’s less chance of messing up the actual PHP code and you can add text etc. without worry of accidentally killing the page (it happens - trust me. Even as an experienced coder, I still mess pages up!).
From a time efficiency perspective, you might also consider that every time you need to make an update you have to go to your FTP, download the file, update it and then re-upload it. With a semi-static system, you just need to go into the Sniplets admin panel in WordPress, tweak the copy and hit “save”. Job done.
Also, Sniplets allow you to *add* PHP code as well - you could gain extra functionality just by putting the relevant code into the Sniplet (again, without worry of destroying your layout).
I hope that explains some of the reasons why you’d want to use this type of system instead of just adding code or text directly to your pages. I’d rather do it this “safe” way than adding potential issues to my site!
Cheers,
Zain
December 11th, 2007 at 11:52 am
This is a very good use of Sniplets. Sniplets is very handy for including any fragile text, especially javascript in your WordPress pages.
A significant use is keeping your javascript safely out of the hands of WYSIWYG editors and/or clients.
I will be using this technique. Thanks Zain.
January 27th, 2008 at 1:41 am
I have WordPress Version 2.3.2 which now has a way to set a static home page, right? So can I now de-activate and delete this WordPress Plugin - Filosofo Home-Page Control .83 ? Thanks for the help, because all these plugins have me confused. Oh, and by the way, no I am not using a static home page. I thought I would, but decided against it and never set one.
Filosofo Home-Page Control .83
Allows you to put pages on the same permalink level as the blog’s directory and to set which page you want to be the “home” page. Go to Options » Home-Page Control to adjust the settings. Works in WordPress versions 1.5+ By Austin Matzko.
March 16th, 2008 at 11:18 am
Hello again my friend!
Getting ready to “snipplet” three more blogs thanks to your good work. This is the best thing to come along in a long time in my opinion. So there is a little error; you did all the hard work, the least “we” can do it a little of the light lifting. Thanks so much for working with me the many hours that you did. I miss e-mailing you! Hope your Christmas plans lived up to your expectations (you were visiting a friend if I remember correctly). Sniplets has certainly lived up to mine. I should dedicate a blog to “I love smiplets”! Carol