Check for grandparents in Wordpress

Posted in Uncategorized on June 29th, 2009 by Jon – 2 Comments

During a recent website revision, a client mentioned that they needed a disclaimer on every one of their product pages. Normally, if the product pages were all set to a certain template, it’d be easy enough to just add that disclaimer into the template. Unfortunately, there was no need to make those pages a special template, so they were all just the default template.

However, all of the pages were descendants of the same great-grandparent, the catalog. I needed to find a way to check if a page was a grandchild of the catalog page, and if so, display the disclaimer.

Here’s the very simple code that made that happen:

<?php $ancestors = get_post_ancestors($post);
if (in_array(4,$ancestors)) echo "4 is an ancestor of the post"; ?>

The code gets all the ancestors of the post, throws them into an array, and then checks to see if the catalog page (in this case, page ID 4) is in the array). If that’s true, we can go ahead and display the information we need to.

Optimizing Order Forms

Posted in Uncategorized on June 12th, 2009 by Jon – Be the first to comment

Recently, my company upgraded their subscriber database. One of the major advantages of this upgrade is that it let our website communicate directly with our database, meaning that (among other things) our order forms could send their information directly to the database.

In writing the code to allow this to be possible, I found quite a few areas that needed improvement. Here is our old order form:

Picture 1

And our new one:

Picture 2

So what were the changes?

  1. The new order form uses fieldsets to clearly seperate the various sections of the form, and help to create a natural progression when entering information.
  2. The labels, field text, and fields themselves are bigger. The last thing someone should need to do is have to squint while they input their credit card number.
  3. Added a confirm email field. Even though it is an important field, and people must type it several times per day, we still found we were receiving a large number of orders with mistyped email addresses. Unfortunately the order may still go through anyway, even though the subscriber will have no way to receive their order, nor be contacted about the problem.
  4. There was only one line for the mailing address, even though a fair number of individuals and even larger number of companies have two lines for their mailing address.
  5. The state and country fields were turned into drop-down lists. This was originally done because our database needed states as abbreviations, while people would sometimes type the whole state name. But I soon realized that people are much more used to selecting their state and country from a drop down. A small note on this: United States is at the top of the list and selected by default. I often find it frustrating on U.S. based sites when the U.S. is listed alphabetically, near the bottom.
  6. I added card type as a drop down. I had initially removed this field, as it seemed to be an unnecessary hindrance since the credit card type can be determined from the first digit. However this led to two problems. First, people would add “Visa” to the beginning or end of their number, thinking they had to put it in some place. Second, by having the user choose the credit card type, it seems to increase the likelihood that they will pay attention to which credit card they are inputting, and type the number correctly.
  7. I added logos for each type of credit card accepted. It was mentioned in a speech at Pubcon that including credit card logos increased conversion by 1%, as they instilled confidence in the buyer. Along those lines, I also made sure that our Better Business Bureau and McAfee Secure logos were always visible.
  8. The submit button was made even larger and placed directly under the previous field.
  9. Several ASP field validators were added or adjusted, including a regular expression validator to confirm the credit card, and a comparison validator to check the two email fields. This allows for more error checking to occur client side, before the user submits their form.
  10. If an order is submitted and rejected by the database, a large error panel is displayed at the top of the page, which describes the error but also provides instructions on how to answer customer service.

When Advertising Fails Spectacularly: GoDaddy Shower Ad

Posted in Uncategorized on February 2nd, 2009 by Jon – Be the first to comment

I registered my first domain with GoDaddy about five years ago. They were one of the few companies back then to offer reasonably priced domain registrations, for around $10, while competitors like Network Solutions still charged $40.

I’ve continue to register domains there over the years, and now have about ten personal and twenty for my work. Over time, they’ve added more and more bloat, and it’s taken more and more clicks to actually purchase a domain. Their management interface is overwhelming now, and the page design itself is quite the eyesore.

read more »