Query by one custom field and order by another – WordPress

This is more of an affirmation than a hack. Since the introduction of meta_query in WordPress 3.1, filtering posts by metadata has become significantly less painful. An added benefit is the ability to use meta_key to sort your results without having to filter by meta_value.

The trick is to let meta_query handle the actual filtering and include meta_key to pass a different meta field to the orderby argument.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
$args = array(
	'post_type' => 'put_post_type_here',
	/* use the new meta_query in WP 3.1 for filtering */
	'meta_query' => array(
		array(
			'key' => 'put_filter_meta_key_here',
			'value' => 'put_filter_meta_value_here',
			'compare' => '='
		)
	),
	/* use meta_key for sorting - but don't specify a meta value */
	'meta_key' => 'put_sorting_meta_value_here',
	/* then order by the meta_key above - use meta_value_num for numbers */
	'orderby' => 'meta_value',
	'order' => 'ASC',
 );
query_posts( $args );

Keep in mind:

  • This query only works for sorting by one meta value. Nested sorting will require a SQL query.
  • Dates and times should be in a valid format for chronological sorting (you don’t want the system to misinterpret AM/PM

Blueprint => Susy

I’m switching from Blueprint to Susy – a step along the trail to semantic DOM markup. Susy seems to play more nicely with Compass, plus there’s some useful tools (css only “grid display”) built in. Check it out!!


iPad App review on AOL’s patch.com

Here’s a review from the debut of the Cape Cod LIFE iPad app I’ve been working on. Snip:

Cape Cod Life? There’s an App for That!

A Cape Cod tradition dives headfirst into the future of publishing.

In the Wild West environment of the early years of the World Wide Web, up and coming, tech-savvy 20 – and 30 – somethings became accustomed to getting their content online, anywhere, anytime, for free.

As a result, many print magazines went out of business, not so much because subscription bases went down, but because advertisers jumped ship, in search of eyeballs on the Internet.

Then came e-readers and pay walls, indicating people were ready to pay for quality content (or rather that quality content providers could not survive without subscriber revenue).

Then the iPad was born. Our very own Cape Cod Life magazine may just be among the very few forward-thinking beacons that see the promise of this new medium. (Despite the raging popularity of the iPad, it’s still ahead of its time; Google “iPad, what’s the point” and you get 3,120,000 page hits linking to skeptics).

At the beginning of this month, Cape Cod Life became the first Cape and Islands lifestyle magazine with an iPad app and the first Cape and Islands publication with a magazine app to deliver content. Cape Cod Life and Cape Cod Home apps are now live on the Apple app store. read on..


iPad App debut press release

This is another press release that went out in New England for the release of the Cape Cod Life iPad App I recently launched. Snip:

Cape Cod Life Publications debuts iPad app

Cape Cod Life becomes first Cape and Islands lifestyle magazine to introduce app 

Mashpee, Mass. (April 7, 2011) –  Cape Cod LIFE, the well-known, 32 year-old Cape and Islands lifestyle magazine, introduced its first iPad app this month.  The app will bring each issue of the magazine to life on the iPad, along with additional interactive content.  Cape Cod LIFE, which is distributed nationwide, becomes the first lifestyle publication on Cape Cod and the Islands to roll out an app for the iPad.

 

The app is available for free on the iTunes App Store; for more information on the app, visit www.capecodlife.com/ipad. It will allow iPad users complete access to each issue of Cape Cod LIFE and its special editions, including Cape Cod GARDENS and Cape Cod ART.  The first issue available for download is the Cape Cod LIFE 2010 Annual Guide, which is accessible for free. Cape Cod LIFE’s sister publication – Cape Cod HOME – will have its own iPad app, which will be launched in late April. read on..


Setup at the Boston Flower & Garden Show

This week I’ve been helping to build the Cape Cod Life Pergola for the Boston Flower & Garden Show. We’re expecting over 100,000 visitors over a 5 day period, and will be debuting our newest publication, Cape Cod GARDENS. I created some fun video reels full of local photography, trivia questions, Google Earth “flyouts”, and some videos from local businesses.