currently I have a little problem with filtering my posts in a widget. I need to filter my posts after a category id and a meta_key. The thingy with the meta_value wasn’t the problem but how can I select the categories then?
The following SQL query is the current status:
SELECT post.*, meta.meta_value AS release_date
FROM $wpdb->posts post
INNER JOIN $wpdb->postmeta meta ON post.id = meta.post_id
AND meta.meta_key = 'date'
I guess you need to pass along the meta value also.
SELECT post.*, meta.meta_value AS release_date
FROM $wpdb->posts post
INNER JOIN $wpdb->postmeta meta ON post.id = meta.post_id
AND meta.meta_key = 'date'
AND meta.meta_value = '09/09/2010'
Didn’t test it so I don’t know if it works.
Cheers!
Viewing 2 replies - 1 through 2 (of 2 total)
The topic ‘Filtering posts after category and a meta value’ is closed to new replies.