I altered my functions.php page to allow me to add extra information to my media.
these fields are: lotteri_ar
photo_year
bild_teknik
and photo_size
I need some help in order to create a query that allows me to search for a few “custom_fields” at the same time to produce the right results.
I am not a 100% sure how to structure the query in order to look for items that have a lotteri_ar = 2011
and bild_teknik = olja
I have the following, but it doesn’t give me what I am looking for.
$querystr = "
SELECT wposts.*
FROM $wpdb->posts wposts, $wpdb->postmeta wpostmeta
WHERE wposts.ID = wpostmeta.post_id
AND wpostmeta.meta_key = 'bild_teknik'
AND wpostmeta.meta_value LIKE 'olja'
AND wpostmeta.meta_key = 'lotteri_ar'
AND wpostmeta.meta_value = $y
AND wposts.post_type = 'attachment'
ORDER BY wposts.post_date ASC
LIMIT 100
"
Any help would be appreciated.
There is a plugin but I am not sure if it works with WP 3.0 http://wordpress.org/extend/plugins/wp-custom-fields-search/