开发者

Wordpress search custom query for custom fields

开发者 https://www.devze.com 2023-02-25 06:15 出处:网络
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 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% s开发者_C百科ure 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/

0

精彩评论

暂无评论...
验证码 换一张
取 消