Custom query filtered by category and custom field
-
Hi,
I want to select the distinct value of custom field “portata” filtered by category and an other custom field.
this is the query to select a custom value by categoryglobal $wpdb; $querystr2 = " SELECT DISTINCT wpostmeta.meta_value FROM $wpdb->posts wposts LEFT JOIN $wpdb->postmeta wpostmeta ON wposts.ID = wpostmeta.post_id 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 wpostmeta.meta_key = 'portata' AND $wpdb->term_taxonomy.taxonomy = 'category' AND $wpdb->term_taxonomy.term_id IN($variabile_c) ORDER BY wpostmeta.meta_value ASC ";
how can I add on other custom field to the filter???
Viewing 7 replies - 1 through 7 (of 7 total)
Viewing 7 replies - 1 through 7 (of 7 total)
- The topic ‘Custom query filtered by category and custom field’ is closed to new replies.