Separating Posts from Pages in Wordpress
April 16th, 2008
I decided that what our wordpress-cross-CMS for Ocean Addict required was the ability to browse through the thousands of expected Pages (pages because of the fact they exist outside of the post timeline as a form of static content) forming the school listings via the inbuilt category system. This was easily achievable by creating a page template specifically for displaying a school listing with the Comments and Categories shown and by using the useful plugin Page Category Plus for replicating the Category selection interface in the admin (I was already aware that this was possible since Pages are simply Posts that are treated differently but still have all the same mySQL fields).
While this side of things worked exactly as expected it threw up a unique issue I hadn’t considered.
While viewing the Category through the file Archive.php, for example http://www.oceanaddict.co.uk/category/sailing-yachting-and-dinghy/ the pages were displayed in exactly the same form as posts which put simply was something I didn’t want to happen. I had to find a way that pages and posts could be displayed differently in the archive page.
Initially I would have thought this would be quite easy for wordpress since it sends other variables to the template like the_ID(); and the_author(); and even a promising-sounding is_page();, but after a LOT of searching I found there was no method of determining the page type value after the SQL statement had run from the variables sent by wordpress itself.
Eventually I came across the solution:
if ( $post -> post_type == 'page' )
So there we go, if you wish to differentiate between pages and posts in your template, this is the line to use.
Add a Comment
The flash actionscript behind this is flexible enough to allow for any size
puzzle to be created and jumbled as many times as I like. In addition to this,
the difficulty of rotating pieces is also a feature.