Smeg Up’s: It appears I linked to the wrong matt (oops, my bad). Apologies to all.
It’s interesting what happens when one metaphorically “looks under the hood” at the code of WordPress.
I’ve discovered that WP has one fatal flaw in it’s presentation to the world. It’s billed as a blog, when in actual fact it’s capable of being a very powerful CMS.
The layout I have come up with, that fits my form and function requirements deviates away from the standard WP post loop. By default posts are shown in reverse chronological order, with the latest post presented first, then rolling backwards through time. For most, that is ideal. WP takes all of a bout 5 minutes to install, grab a theme, install it and your go for launch.
However during the re-creation of this layout, I stumbled upon three (in particular) impressive resources to assist when one wishes to get their ‘code’ hands dirty.
I would be remiss if I did not at this point mention Phu Ly’s
excellent posts on
advanced
post handling. Without Phu’s excellent posts on creative uses for query_post I would have been lost before I had even begun.
The next, has to be the wordpress codex. There are some fantastic entries on advanced post and tag use. I suggest any WP user bookmark this location now, you will not be disappointed.
Finally, but certainly not leastly, are the fine WP forums. Many fine knowledgeable folks dedicate much time to support each other. One of the greatest WP advantages over other CMS and blog softwares is this kind of support. This entry on `get_posts()` for example was most useful.
The layout is based on two sections of code, across two pages (for me splitting the code across two pages reduces complexity in any one page) that permit granular control over post formatting and layout. This deviates away from standard WP fair, but is an example of what can be accomplished with relative ease. For the first post, one additional code snippet is added to the loop to generate a single (latest) post and then drop out of the loop:
`query_posts('showposts=1');`
As we know, I then display del.icio.us links using the popular ‘del.icio.us cached’ plugin. From there a second ‘loop’ through the posts in the WP database is run, to display the rest of the posts. This snippet is a little longer, yet is reasonably self explanatory:
`$posts = get_posts('numberposts=10&offset=1'); foreach ($posts as $post): setup_postdata($post);`
So, stepping through this we see that an array is set, being `$posts`, which displays a maximum of 10 posts, and uses an offset counter to skip through n posts, where n is 1 in this case.
This pre-sets our ‘remainder’ posts structure, with standard WP template code used to complete the process. This is just a simple example of what can be accomplished. Over time I hope to gain a greater understanding of the WP template tags to see what is truly possible.
Addendum: Shortly after posting this photomatt posted a link to this brilliant wordpress template primer.
≡ This is a journal entry relating to the topics of code, design, function, noteworthy.
Brendan Borlase is a Systems and Network Administrator living in Adelaide, Australia, having lived, worked and breathed Information Technology for over 12 years. Learn more.
Feedback is encouraged. If you would like to read more, consider subscribing to the regularly updated RSS Feed.


Apr 22nd, 2005 at 1:32 pm
I couldnt agree more, Im using WP to do our companies site at the moment, and very nicely it does it too. Its still in development, but when its live Ill send you a link so you can have a ganders. WPs flexibility keeps on amazing me.
Apr 22nd, 2005 at 1:44 pm
Oh, I should also add that my apparent knowledge of PHP is starting to scare me, I really shouldnt know this much.
Apr 22nd, 2005 at 9:11 pm
*chuckle* I know the feeling.. Over the last few days the ’scales have fallen from my eyes’ and php / wordpress code is making sense to me. It’s all just a little unnerving. :)
Apr 26th, 2005 at 4:42 am
I?ve discovered that WP has one fatal flaw in it?s presentation to the world. It?s billed as a blog.
My Semiologic theme and CMS lets you change the default ‘blog behavior’ of WordPress (e.g. add a static front page or make the front page opt-in) in one click.
Apr 26th, 2005 at 4:43 am
As Im getting deeper into the WP code (so to speak) Ive also found things Id liek more control over but cant seem to though.
Like for instance displaying of categories next to posts. Id like to show the children of one category first and bigger and then show the children of another category next and smaller.
The reason for this is that Id like to show the client and then the discipline for that news item smaller after it - for instance
April 2005, The Client - Advertising, Graphic Design
Hopefully that all shows up correctly
Apr 26th, 2005 at 6:17 am
Hrm, not sure matthew. You’re basically talking about separating out elements of nested categories, then applying mark-up against each level independently from what I can tell..
I take it the codex is a bit vague in the category tag world?
Apr 26th, 2005 at 6:23 am
Denis,
I had a quick look at your theme prior to re-building my layout (well, it’s more a template than just a theme really) and it looks pretty cool.
Certainly hints at what can be done with a bit of work. :)
Apr 26th, 2005 at 6:25 am
not so much vague as just showing the simple facts, and tbh I didnt expect it to explain how i could do this. What would be nice is if you could hide/show certain categories and their children for the post. Then you can call it twice and just show what you need for each instance.
I guess id have to write my own code to do that as it would be quite specialised.
on a sidenote, something I noticed with the wp_list_cats function is that you can hide categories but not them and their children or indeed choose to just show a category and its children, not easily anyway (it ends up showing empty categories too) - which seems very odd and a big oversight to me.
Apr 26th, 2005 at 6:33 am
Cheers Brendan ;-) I try.. :-D Im still happy with the look even so long after releasing it. I just have to try to keep up with K2 now ;-)
I tried to use a few hooks in there like the conditional showing and hiding of pings and highlighting of the authors comments and indeed noted authors comments. I noticed many of the winners in the theme compo (slightly sore subject still but hey choice is choice) didnt use anything like that which I think is a shame its its relatively easy but shows some of the more complicated aspects to WP.
Im tempted to integrate some of my tweakings for my current site into a Mallow v2 (along with Michaels idea that if plugins are loaded it should take advantage of them), unfortunately that will *greatly* complicate the theme to a degree that it might be incomprehensible to new users (who can easily get confused anyway) so maybe I should just release my site stripped of plug in code.. or maybe not I dont want to many clones around.. hmm anyway, Ill think about that one maybe.
Apr 26th, 2005 at 6:57 am
matthew,
I was actually referring to Denis’ post, but agree that your current layout is also top shelf stuff. :)
You’ve shown that a single column layout can work and work well.
About the only suggestion I can think of, is use custom functions in the template, that draws upon a ‘code’ php file (like you do now with the handling of some custom code).
It’s then a case of remarking out those functions in the template files, with all the plugin code in the code file, suitably documented so beginners can follow it.
Basically one place to enable/disable plugin functions which reduces the risks of
newbiesbeginners hacking half a dozen template files, then getting stuck. :)Apr 26th, 2005 at 7:48 am
Opps - red-faced emoticon (I forget what symbols I should use) ;-)
My current site uses 22 different files in the theme so Id need to tweak it somewat for mass consumption
Apr 26th, 2005 at 8:10 am
Only 22? heh damn dude. :)
Apr 26th, 2005 at 8:15 am
lol, down from 30+ after my recent tidy up :-D
Apr 26th, 2005 at 8:20 am
**chuckle** :D
Apr 26th, 2005 at 8:44 am
Congrats! You figured out someone everyone else already knew.
Apr 26th, 2005 at 8:48 am
Something, perhaps?
If you’re going to try to be a wiseass, it pays to get it right, or you just look like an ass.
Apr 26th, 2005 at 9:57 am
I’ve toyed with the idea of using WP as a CMS, the main problem is, while it’s a great publishing system and offers a lot of versatility in presenting content, it still lacks some of the main features dedicated CMS’s have. In order to use WP as a complete CMS you will need to add many of these modules as plug-ins and they will never integrate 100%, in addition to many modules that can’t be added as plug-ins and must be hardcoded.
Apr 26th, 2005 at 4:55 pm
it still lacks some of the main features dedicated CMS?s have
Like? I’d be curious as to what your criteria would be, the features you require, etc. :)
Many of the plugins are actually extremely powerful in their own right, and can be integrated in WP well.
Apr 27th, 2005 at 3:35 am
Stilllearn from this article
Nice Article. Thanks
Apr 27th, 2005 at 4:42 am
Ive used a couple of full on CMS programs, I dont know the names they may well have been custom as they were done for clients, but to be fair Wp doesnt come far off with its features.
In line editing is the big thing I noticed, but touched pretty much sorts that, if only it was WYSIWIG. Also they had more powerful management of static pages and then also elements on a page, so you can for example alter the sidebar and elements within it in the editor and also inline graphically rather than the code.
Asides from that WP is pretty good - considering its free, which when you remember some of these CMS can be in the thousands of your chosen currency its not bad.
Apr 27th, 2005 at 6:34 am
All these hacks do not hide the fact that Wordpress is nothing more than a fancy reincarnation of your average PHP application: PHP code mixed with SQL code mixed with HTML code all in the same file. How about bringing some modern programming concepts to PHP? I really wonder how anyone can code custom applications on top of that… OOP anyone? Separation of presentation and logic, encapsulation of data access code in their own libraries/classes, etc.
It really hurts the PHP community more than it helps to have such a popular application coded like that. The view that people have from PHP coders is that of a bunch of guys that hardly know enough about programming to slap together some crap logic and run some MySQL queries…
Apr 27th, 2005 at 7:09 am
“… is nothing more than a fancy reincarnation of your average PHP”
Following that logic, so is virtually anything else that uses both php and sql, which most CMS and weblog softwares do. PHP is very good at rendering dynamic content, amongst many other tasks, however it has never been, nor will it be a suitable product to store data with.
“Separation of presentation and logic, encapsulation of data access code in their own libraries/classes, etc.”
Perhaps you might like to make some suggestions on ways to optimise code and methodologies.. Throwing stones is easy.
“.. a bunch of guys that hardly know enough about programming to slap together some crap logic and run some MySQL queries”
Again, care to provide a better suggestion? Some optimised and semantic code perhaps?
I have no problems with folk expressing opinions here. However taking pot shots without providing something of substance (other than stone throwing) doesn’t prove WP has it wrong IMHO. A perfectly semantic, structured, optimised and clean approach may be the ideal you’d expect, however how simple is it going to be for Joe Average who suddenly has to get to grips with advanced PHP techniques and daunting librarys?
You are of course perfectly welcome to develop something you suggest others should. :)
Apr 27th, 2005 at 7:22 am
Theres a saying round are way, “It’s all left, right, fire”. Referring to games which in essence havent changed since Space Invaders.
Seems relevant . maybe
Apr 27th, 2005 at 7:28 am
?It?s all left, right, fire???
You forgot “duck”. :)
Apr 28th, 2005 at 9:56 am
Psst… you’re linking to the wrong photomatt.
Apr 28th, 2005 at 10:14 am
Oh crap - i didn’t even notice. :(
Thanks tom, fixed.