I have some problems making a post filter in my sidebar..
I would need to display all the recent posts that are from the same category as the current post, and must have the same value from a custom field as the current displayed post.
I have tried something like that, but thn there is the category problem
<?php $cur_post_value = get_post_meta($post->ID, 'town', true); $other_posts_with_value = " SELECT wposts.* FROM $wpdb->posts wposts, $wpdb->postmeta wpostmeta WHERE wposts.ID = wpostmeta.post_id AND wpostmeta.meta_key = 'town' AND wpostmeta.meta_value = '".$cur_post_value."' AND wposts.post_status = 'publish' AND wposts.post_type = 'post' ORDER BY wposts.post_date DESC LIMIT 4 "; $other_posts_array = $wpdb->get_results($other_posts_with_value, OBJECT); ?> <?php if ($other_posts_array): ?>