Plugin Author
Ajay
(@ajay)
The list of post IDs are one of the pending features to be implemented either in core or via an addon
Are you filtering the where clause to add the exceptions?
https://github.com/WebberZone/better-search/blob/92a77cfcee9d448a8d3f628e1b291b8f5bc01c87/includes/query.php#L151
no, I added the above in the SQL statement in better-search.php in function bsearch_install:
SELECT blog_id FROM $wpdb->blogs WHERE archived = ‘0’ AND spam = ‘0’ AND deleted = ‘0’ AND NOT IN (‘1877 2020’)
How would I amend the where statement in query.php?
That’s not really the way to do it stewagner,
Ajay is pointing you to the where filter.
You can use it like this:
function my_custom_posts_where($where) {
// Edit the where part of the query, add the NOT IN part
$where .= "AND wp_posts.ID NOT IN (3521, 3519) ";
// Return the where part to the plugin
return $where;
}
add_filter('bsearch_posts_where', 'my_custom_posts_where');
Although I’m not entirely sure the part I added to your query will fix it, this is the way to add parts to the query.
Oh and by the way, you write this code in your functions.php of your theme (if you are not using your own theme, use a child theme to make sure your overwrite will not be removed in the next update of your theme).
I added that function to the end of my theme’s functions.php (with my IDs) but then search stopped finding anything. So I threw it out again.
?
Plugin Author
Ajay
(@ajay)
jifuss’ function is the right way to do it. Does this work?
function my_custom_posts_where($where) {
// Edit the where part of the query, add the NOT IN part
$where .= " AND {$wpdb->posts}.ID NOT IN (3521, 3519) ";
// Return the where part to the plugin
return $where;
}
add_filter('bsearch_posts_where', 'my_custom_posts_where');
… no, same result: every search results in 0 hits 🙁
Please check again.
Plugin Author
Ajay
(@ajay)
Can you please install query monitory plugin and then check the search results page and see what queries are generated?
I uploaded a screenshot of the result here:
Is it want you wanted?
Something more like this probably.
aha, please reload the screenshot!
… one “.” too much right?
or is “$wpdb->posts” undefined?
Plugin Author
Ajay
(@ajay)
That’s right. I missed a line.
Please add global $wpdb; as the first line after the function line
BINGO – thank you very much!!
Will you implement a more convenient ID exclusion in settings soon?