Alright folks, so APPARENTLY I managed to solve this myself.
This code was provoking the “Starbucks case” that I was explaining before
if(!empty($keywords)){
$args['s'] = $keywords;
$words = explode(" ", $keywords);
foreach($words as $word){
$slug = slugify($word);
$categoria = get_category_by_slug($slug);
if(!empty($categoria)){
array_push($cats, $categoria->cat_ID);
}
}
$args['category__in'] = $cats;
}
I changed it to
if(!empty($keywords)){
$args['s'] = $keywords;
}
And now it works. It looks like the idea of searching if there was any category slugifying the words entered in the searchform was a bad idea (or at least, I was doing it wrong), because when I used category__in, I was forcing WordPress to fetch ONLY the posts that had THAT TITLE and belonged to THE CATEGORY with the same name.
Problem solved 🙂