web design web development wordpress cms business blogs

A A A

Help from a LinkedIn Group: Ordering WordPress Custom Field Items

Author: ; Published: May 21, 2010; Category: Design/Development; Tags: , ; No Comments

In general, I’m not as thrilled with LinkedIn as I had hoped I’d be. Like a lot of social media platforms, it draws its share of spammers, shills, and snake-oil salespeople. However, one LinkedIn group I belong to has proven itself to be of benefit time and again: the WordPress group. I’ve gotten useful answers for several WordPress issues I’ve faced over the last several months. There are some really capable and helpful people in the group. I was once given a solution to a problem by Mike Little, who I recognized only later is the guy who, with Matt Mullenweg, started the WordPress project.

Most recently, I needed a way to order WordPress custom fields easily (easily enough that it made sense to clients who would have to maintain their site). By default, custom field items are displayed in the order in which they are created. This is a problem if you want to add a new item and display it at the top of the list.

Mike Schinkel, a web marketing strategist from Atlanta, stepped in with a solution. (How cool is that? I can get coding assistance from someone several hundred miles away!) Mike Schinkel is one of the more active and helpful folks on the LinkedIn WordPress group, and he’s worth connecting with and following. He runs a WordPress business conference (among other conferences) and is Executive Director of Startup Atlanta. I’d guess he’s fairly busy, but he takes time help people like me with limited coding skills.

His solution is so clean and simple I wanted to share it here. One of the beauties of it is that, not only does it organize the custom field items on the page in the order you want, but it also organizes the items in order in the page admin area, taking advantage of WordPress’ default alpha organization.

Essentially, you create custom field items with names like so: item-1, item-2, item-3, etc. As you might guess, item-1 is meant to show first on the custom field listing. Want to make item-1 show second? Change the custom field name to item-2, then rename the other items to complete the reorganization (you can’t have more than one value for each name in this scenario).

On the page template, the code to call the items in order looks like this:

<?php
     for($i=1; true; $i++) {
     $item = get_post_meta($post->ID, "item-$i", true);
     if (empty($item))
     break;
     echo '<div class="itemdiv">'.$item.'</div>';
    }
?>

I used this to display thumbnails and a short description for artwork on a recently launched artist’s website. As she adds new pieces, or if she decides to emphasize different pieces on a category page, she can easily rename the existing custom fields to reorganize items.

One of the caveats of this solution is that the custom field names must start with -1 and be sequential. Going from "item-1" to "item-3", with no "item-2", breaks it.

Having a website? Meaningless. Using a website? Priceless.

Author: ; Published: May 12, 2010; Category: Business, Communication, Marketing, Zeitgeist; Tags: , , ; 3 Comments

hammer

Most people think having a website has value. They’re wrong.

Lots of people and businesses and organizations have websites (although as recently as a year ago, only 37% of US small businesses had one).

But having a website is sort of like having a hammer. Just because you own one doesn’t mean you’re building a house, or even putting up a shelf. If the hammer sits unused in the toolbox, you might might as well not have a hammer, for all the good it’s doing you.

Websites are like that. They’re tools. Used properly, they can help you build a business or start a movement. Left un-utilized on your webhost account (never updated, no interaction with readers, etc.—you know the type), they accomplish nothing.

Primarily, websites are comunication/connection tools. Once you’re good at using your website for communicating and connecting (as with most tools, some practice is required for you to use it effectively: expect an occasional sore thumb), your website can also shoulder some of the burden of sales and delivery of goods and services. But first, you have to successfully use your website for communicating and connecting. (FYI, websites make very poor “look-how-impressive-we-are” tools, though that’s primarily how businesses use them.)

Most of us are reasonably good at dreaming and talking about what we would do if we had the means. We’re not nearly as good at following through when the means is right in front of us. “If I had a hammer,” the old folk song used to say.

Websites, particularly those on platforms like WordPress, are tools that provide us with the means to pursue our goals. But they have to be used. Ladies and gentlemen, pick up your hammers and let’s “hit it.”