Wordpress: Get Posts By Custom Field Values

January 3rd, 2009

Thought Wordpress nerds might find this useful, a function to retrieve a list of posts by passing in a custom filed key=>value pair, with an optional count parameter.

Just drop this in your “functions.php”:

function getPostsByMeta($key, $value, $count = -1)
{
    global $wpdb;
 
    $sql = "SELECT DISTINCT wp_posts.post_title,
    wp_posts.ID FROM $wpdb->posts,
    $wpdb->postmeta 
    WHERE $wpdb->posts.ID = $wpdb->postmeta.post_id 
    AND $wpdb->posts.post_status = 'publish' 
    AND $wpdb->postmeta.meta_key = '$key' 
    AND $wpdb->postmeta.meta_value = '$value' 
    ORDER BY post_date DESC";
 
    $sql .= ($count != -1) ? " LIMIT ".$count : "" ; 
 
    return $wpdb->get_results($sql);
}

and then you can use it like this:

$news_home = getPostsByMeta('_tb_post_section', 'News', 3); 
 
<?php foreach ($news_home as $news) : ?>
    <!-- OUTPUT TEMPLATED HTML -->
<?php endforeach; ?>

Files from Wordcamp Session

September 27th, 2008

Here are the files from my presentation today at Wordcamp Portland.

PDF of my Keynote

Email Update Plugin Files


…. trust me. I have a lot more to say about Wordcamp, but I’ll have to get to it tomorrow - I’m exhausted. That was a LONG day.

Electrolux Virtual Kitchen

September 23rd, 2008


URL: http://www.electroluxappliances.com/node58.aspx
AGENCY: Struck Creative / DDB-NY
LAUNCH: January 2008
ROLE: Lead Developer


I relied heavily upon Arthur Debert’s Bulk Loader to create this video and audio heavy media site. Media files load in the background and you view other content, to create as seemless an experience as possible.

GM USED CAR AMBUSH

September 22nd, 2008


URL: http://www.usedcarambush.com/
AGENCY: STRUCK Creative
LAUNCH: July 2008
ROLE: Lead Developer / Technical Architect


This was the last project that I worked on at STRUCK before I left for NEMO. The site is built entirely in ActionScript3 and I personally built the Papervision 3D powered van interior, and the media queue and streaming system.

HP + VOODOODNA

September 22nd, 2008


URL: http://www.hp.com/voodoodna/
AGENCY: NEMO
LAUNCH: June 2008
ROLE: Lead Developer / Technical Architect

The Wi-Life

September 21st, 2008


URL: http://thewilife.urbandaddy.com/
AGENCY: Left Fields Labs
LAUNCH: August 2008
ROLE: Lead Developer
TECHNOLOGIES: Flash


Flash based site for UrbanDaddy and Sony to help travelers locate Wi-Fi hot-spots in San Francisco and New York. ActionScript 3 that integrates with the flash-based Yahoo Maps API.

UTAH OFFICE OF TOURISM

September 21st, 2008


URL: http://utah.travel/
AGENCY: Struck Creative
LAUNCH: March 2008
ROLE: Lead Developer
TECHNOLOGIES: Flash, Python + Django


Flash based site I did while at Struck for the Utah Office of Tourism. The data is all dynamic and is pulled from a Django based CMS that allow the client to update the content at any time.

I’M SPEAKING AT WORDCAMP PDX

September 21st, 2008


I am speaking this Saturday September 27th @ WordCamp Portland.


I’ll be talking about extending the functionality of Wordpress by writing custom plug-ins, and creating your own administration menus & functionality.


Registration is still open but they’re capping attendence at 150, and I hear that they’re pretty close - so if you wanna go register now.

GRANT SKINNER ON AS3 RESOURCE MANAGEMENT

September 21st, 2008

This is an oldie but a goodie - Grant Skinner gives the straight dope on Garbage Collection and resource management in ActionSctipt 3. Topics that are all too often overlooked.

While on the subject you might also want to check out his articlce Understanding the DELETE Keyword.

PYTHON: BACKUP TO S3

September 21st, 2008

Djangonaut Simon Willison has published a simple Python-based S3 backup script.

“One simple strategy for backing up a server to S3: a single backup_to_s3 function which takes your S3 authentication details plus three (optional) dictionaries specifying directories, files and commands to be backed up.”

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
backup_to_s3(
    access_key = 'your-access-key',
    secret_access_key = 'your-secret-access-key',
    bucket = 'your-backup-bucket',
    directories = {
        'svnroot': '/var/svnroot',
        'www': '/var/www',
    },
    commands = {
        'test.sql': 'mysqldump -u root test',
    },
    files = {
        'passwd': '/etc/passwd',
    }
)


John Stainer from Battles pays a visit to the Seoane studio.



“We’re not sure how deep into the goof juice the Kids in the Hall were when troupe funnyman Scott Thompson started sulking and playing Portal in the back of the tour bus, but something got into Kids during this sad little gaming session.”



via kotaku