My client who rents pop-up campers needed a simple, easy-to-manage guestbook for his redesigned website. He had a clunky script on his old site that he said had been nothing but a source of spam for years – could I do something better? Of course I could.

I looked into the available plugins; there were only a couple that were compatible with the current version of WordPress, and when I tried them I found they were not going to work, mainly because I couldn’t easily add the extra custom form fields I needed.

So I decided to make my own.  In WordPress I created a page called Guestbook. I used the TDO Mini Forms plugin to create my input form. It was easy to configure for moderation by my client and for Akismet spam protection.

Making the Input Form

I set the form to create a new post for each submission, submit it to the ‘guestbook’ category, then built a custom form. I used two custom field widgets (TDO Mini Forms widgets) for Name and Hometown, a content widget for the post name and comments, and then a simple one-question captcha. All of these widgets are drag-and-drop (there are many others available, including image uploader) and very customizable.

Once the form’s built, it can be hacked to rearrange fields, modify CSS, etc. You can also export a final copy of your form to a text file to later be imported for reuse on other projects.

Getting the Form Into the Page

I created a custom category template page where I limited the category to be displayed to ‘guestbook’ by using the ‘include’ parameter for wp_list_categories, set to category 10 (my guestbook posts) like this:

Then in WordPress I set my Guestbook page to use that new custom category template.

I used the TDO Mini Form widget to put the form into the sidebar on my Guestbook page. Nothing to do here really except restrict where it displays with Widget Logic:

Styling the Form

Custom styling of the form is easy, the file is /plugins/tdo-mini-forms/tdomf-style_form.css. I only made a couple of small changes, mostly redoing the ‘submit’ button to match the others on the site.

Styling the Page and Guestbook Posts

I added some text at the top of the page by putting it into the Description field for the category. Then I wanted to style each blog post with a border and some additional changes in presentation.

The CSS was simple – I made the posts narrower, put a larger margin underneath them, added padding, added a subtle background color and border, and made the headlines a little smaller and with a different font than the page headline:

Using Filter Hooks to Control What’s Displayed for each Post

I’m using Theme Hybrid, so this part was a little easier than it might normally be. Here’s a good overview of filter hooks and how to use them, and this is what’s built into Theme Hybrid. And, here’s a hooks database so you can see all the filter and action hooks available in WP 3.0.

What I wanted to do:

  • Remove the link from the post title
  • Change the byline to show only the publish date
  • Show all of the post content instead of an excerpt

I found that I can do all of this with hooks in my theme’s functions.php file.

Here’s the final product in action.

That’s pretty much it – now when someone submits a comment (that isn’t flagged as spam by Akismet) my client gets an email notification. He logs into WordPress and goes to TDO Mini Form’s moderation panel, and can then edit, trash or publish the post as he likes. A simple, solid solution that took less time than anticipated (which is always nice!).

This seems trivial, but it took me hours to troubleshoot this problem. I hope I save someone else from that.

WordPress custom post types are great – they make it so easy to create any kind of ‘cataloged’ posts, like a portfolio, or a library of DVD’s, or products to sell. I’m building a portfolio and testimonials using custom post types and for the most part this has gone really smoothly.

The one major hiccup was pagination. If you want to display say 10 custom posts on a page (an actual WordPress ‘page’) and then have the user be able to flip to the next page, you’ll need to use some kind of pagination like WP Page-Navi.

I spent hours trying to get paging to work on my testimonials, until I finally found a very important note in a discussion thread about custom post types:

You cannot create a Page using the same string name as your registered custom post type.

That means that if I register the custom post type ‘testimonials’ I cannot display it on a page named Testimonials. One of them has to be different.

Whew. I wish I’d found it earlier, but making that simple change fixed my pagination issues in a second.

Work was a little slow midsummer. It’s really picked up in the last 4-5 weeks – a number of new projects getting started, and enough work that I hired a second intern this week. But during the lull I seem to have strayed a bit from my ‘ideal client’ mentality.

I’m working on a few jobs where the client brought the design and just wanted some ‘design advice’ and coding. I won’t do that again anytime soon – I find it really frustrating to offer well-considered advice, only when asked for, and have it ignored, or worse, be told that I don’t know what I’m talking about. That’s not the kind of client I enjoy working with. I like partnering with people who value what I can bring to the table, not just my skills as a codemonkey. But here I am…

I took one of those jobs because it offered me a good opportunity to get some experience in a niche market where I’d never done any web development work. I think that was a good move and will be worth some frustration; the development parts are challenging and I love a challenge.

But the other one, it’s one of those situations where my instinct was on the fence. It didn’t say ‘run away’ clearly, which is what usually happens. It just said ‘meh.’ So I took the project mostly because I was in a slow work period. I’m being paid fairly; it’s just frustrating to see what could be a really beautiful website  build around a finely-detailed, high-end product instead looking like something from the mid-to-late ’90’s. Sigh.

Teeth gritted, I carry on and learn another lesson about the importance of choosing the right people to work with for the right reasons.

Yesterday around lunchtime I opened up Thunderbird to discover that about 40 emails were missing out of my inbox.

I wasn’t that concerned because I’ve had things like that happen before, but as I went through the numerous recommended recovery steps and still had no email, I started thinking about what was actually in the inbox.

A few were digests I hadn’t had a chance to read yet, a couple were newsletters I wanted to go through later, but most of them were client correspondence I’d already replied to, or was awaiting a reply to. Nothing horribly important.

So now I only have four emails in my inbox. That’s a lot better. I’m still going to try to recover that missing mail, but what happened was not actually that bad. That’ll teach me to clear out my inbox more often, maybe.

On Saturday night I downloaded the Hybrid WordPress framework and installed it on the site where I’ll be reworking my main website. By Sunday afternoon, I was a total convert from WP Framework.

I learned more about advanced WP custom theming in a day than I have in the last month. Very excited to delve more deeply into Hybrid and all its possibilities.