I am having some trouble pulling multiple custom post types from a Custom Wordpress Query. The reason I am creating a custom Wordpress query rather than using query_posts or WP_query is because I am sorting my posts based on information added by a voting plugin, and have to join that plugin's table, so the built-in queries are not an option.
My question is how can I include multiple custom post types in the same query? At present, my query looks like the following:
$query = "
SELECT wposts.*
FROM $wpdb->posts wposts, $wpdb->postmeta wpostmeta
WHERE wposts.ID = wpostmeta.post_id
AND wposts.post_status = 'publish'
AND wposts.post_type = 'TWO_POST_TYPES'
AND post_date >= '$startdate'
AND post_date <= '$enddate'
GROUP BY wposts.ID
";
I am trying to put two different custom post types into the wposts.post_type part, which we can call type1 and type2. What I have already tried is the following, with no luck:
array('type1', 'type2')'type1, type2'
I have also tried passing both of these as variables in the query, but also no luck. Would anybody be able to give me a hand?