A search filter function, that I can't quite make…
-
Hi,
I am trying to make a function in my functions.php file. Its supposed to loop through search results, find out if they are using a certain category, if they are add them to an array, exclude all id’s in that array from showing in search results. Here’s what I have, I just don’t understand much about this….
function filter_where($where = '') { global $wpdb;//is this needed? if ( is_search() ) { if(is_page_template('landing.php')) { echo 'yes!'; } // this is where I will add id's to the array. $exclude = array(286); for($x=0;$x<count($exclude);$x++){ $where .= " AND ID != ".$exclude[$x]; } } return $where; } add_filter('posts_where', 'filter_where');
I have never done anything like this and would like to learn how to use the filters properly…Thanks
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘A search filter function, that I can't quite make…’ is closed to new replies.