Hi. I have a form on my site that asks users to choose the value for each of 4 custom fields. I then have a query that results in all of the posts that match the values they gave. I want to add to the form so the user can also choose category and author so that the query only fetches posts that match all the custom field values and the category and the author chosen.
So far, I have this, which works for the custom fields query:
$querystr = " SELECT wposts.* FROM $wpdb->posts wposts, $wpdb->postmeta wpostmeta, $wpdb->postmeta wpostmeta2, $wpdb->postmeta wpostmeta3, $wpdb->postmeta wpostmeta4 WHERE wposts.ID = wpostmeta.post_id AND wposts.ID = wpostmeta2.post_id AND wposts.ID = wpostmeta3.post_id AND wposts.ID = wpostmeta4.post_id AND wpostmeta.meta_key = 'gametype' AND wpostmeta.meta_value LIKE '$gametype' AND wpostmeta2.meta_key = 'gameformat' AND wpostmeta2.meta_value LIKE '$gameformat' AND wpostmeta3.meta_key = 'gamelimit' AND wpostmeta3.meta_value LIKE '$gamelimit' AND wpostmeta4.meta_key = 'numberoftables' AND wpostmeta4.meta_value LIKE '$numberoftables' AND wposts.post_status = 'publish' AND wposts.post_type = 'post' ORDER BY wposts.post_date DESC ";
I've been reading a lot of posts on here (in particular, I tried the code from: http://wordpress.org/support/topic/121011?replies=15 and the code from: http://wordpress.org/support/topic/161154?replies=10" but I keep getting 'Parse error: syntax error, unexpected T_VARIABLE in' even when I copy the code exactly and change only the meta_key name.