[Resolved] Restricting Custom SQL by Certain Categories
I want to exclude two categories on my index template, however, I can’t quite figure out the syntax for the custom sql query.
I’ve taken a look at Otto42’s custom category select statement, however it also restricts and orders it by custom meta data.
$querystr = " SELECT $wpdb->posts.* FROM $wpdb->posts LEFT JOIN $wpdb->postmeta ON ($wpdb->posts.ID = $wpdb->postmeta.post_id) LEFT JOIN $wpdb->post2cat ON ($wpdb->posts.ID = $wpdb->post2cat.post_id) WHERE $wpdb->postmeta.meta_key = 'paragraf' AND $wpdb->posts.post_status = 'publish' AND $wpdb->posts.post_type = 'post' AND $wpdb->post2cat.category_id IN (1,2,3) ORDER BY $wpdb->postmeta.meta_value ASC ";
I just want to exclude two categories and order by date. Can anyone help?
- The topic ‘[Resolved] Restricting Custom SQL by Certain Categories’ is closed to new replies.