Exclude category from custom search
-
I’m running a couple of custom queries on custom post templates, and can’t figure out how to exclude a specific category from results.
In my database, in the wordpress_posts table, all the “post_category” fields are 0. However, the posts are in their own categories, and working right. So I’m not sure where the category gets saved.
I’m using this query:
$querystr = " SELECT DISTINCT wordpress_posts.* FROM $wpdb->posts wordpress_posts WHERE wordpress_posts.post_content LIKE '%$first_name $last_name%' AND wordpress_posts.post_status = 'publish' AND wordpress_posts.post_type = 'post' ORDER BY wordpress_posts.post_date DESCI’m defining first_name and last_name from custom fields in WordPress.
I’ve tried:
$querystr = " SELECT DISTINCT wordpress_posts.* FROM $wpdb->posts wordpress_posts WHERE wordpress_posts.post_content LIKE '%$first_name $last_name%' AND wordpress_posts.post_category != '1302' AND wordpress_posts.post_status = 'publish' AND wordpress_posts.post_type = 'post' ORDER BY wordpress_posts.post_date DESCBut that didn’t work. Can someone point me in the right direction? (which, with my luck, is right in front of my face)
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
The topic ‘Exclude category from custom search’ is closed to new replies.