[wp-hackers] Custom queries
Dion Hulse (dd32)
wordpress at dd32.id.au
Sun Mar 27 10:31:08 UTC 2011
Honestly, Scrap whatever you're doing there and use the Taxonomy Queries and
Meta queries in WordPress 3.1..
Use these:
http://scribu.net/wordpress/advanced-metadata-queries.html
http://ottopress.com/2010/wordpress-3-1-advanced-taxonomy-queries/
On 27 March 2011 21:24, Hannit Cohen <hannit at codeart.co.il> wrote:
> Hi,
> I'm developing a real-estate site and need a custom search form.
> The site search is based on price, number of rooms, location and
> accommodation type (condo, appartment, etc...)
>
> I'm using accommodation type and location as custom taxonomies.
> price and # of rooms are special fields.
>
> Here is the current custom search I'm using:
> SELECT wposts.*
> FROM $wpdb->posts wposts
> LEFT JOIN $wpdb->postmeta price ON (wposts.ID = price.post_id AND
> price.meta_key = 'price')
> LEFT JOIN $wpdb->postmeta rooms ON (wposts.ID = rooms.post_id AND
> rooms.meta_key = 'rooms')
> LEFT JOIN $wpdb->term_relationships ON (wposts.ID =
> $wpdb->term_relationships.object_id)
> LEFT JOIN $wpdb->term_taxonomy ON
> ($wpdb->term_relationships.term_taxonomy_id =
> $wpdb->term_taxonomy.term_taxonomy_id)
> WHERE wposts.post_status = 'publish'
> AND price.meta_value BETWEEN $pmin AND $pmax
> AND rooms.meta_value BETWEEN $rmin AND $rmax
> AND $wpdb->term_taxonomy.taxonomy = 'category'
> AND $wpdb->term_taxonomy.term_id = $catid
>
> I want to add the custom taxonomies select to this query (i.e. if I get
> type=30) add that to the conditions.
> since I have to custom taxonomies I need something that works for multiple
> values with AND condition...
>
> Any idea will be appreciated,
> Thanks
> Hannit
>
> --
> Hannit Cohen
> CodeArt
> +972-54-6280-490
> hannit at codeart.co.il
> http://codeart.co.il
> _______________________________________________
> wp-hackers mailing list
> wp-hackers at lists.automattic.com
> http://lists.automattic.com/mailman/listinfo/wp-hackers
>
More information about the wp-hackers
mailing list