Ya lo solucione al final
Gracias por la ayuda dejo el código de la solución
Código PHP:
function getLugar($slug){
$db = new connexio();
$lugar = $db->query("SELECT * FROM wp_terms WHERE slug ='$slug'");
$fila = $lugar->fetch_array(MYSQLI_ASSOC);
$lugar = $fila['term_id'];
$tid = $db->query("SELECT term_taxonomy_id FROM wp_term_taxonomy WHERE term_id='$lugar'"); // torna 50 de term_taxonomy_id que es de bares
$fila2 = $tid->fetch_array(MYSQLI_ASSOC);
$tid = $fila2['term_taxonomy_id'];
$tots = $db->query("SELECT * FROM wp_term_relationships WHERE term_taxonomy_id = '$tid'");
$i = 0;
while ($fila3 = $tots->fetch_array(MYSQLI_ASSOC)){
$arr[$i] = $fila3['object_id'];
$i++;
}
return $arr;
$db->close();
}
function getBares($slug2){
$db = new connexio();
$bares = $db->query("SELECT * FROM wp_terms WHERE slug ='$slug2'");
$fila = $bares->fetch_array(MYSQLI_ASSOC);
$bares = $fila['term_id'];
$tid = $db->query("SELECT term_taxonomy_id FROM wp_term_taxonomy WHERE term_id='$bares'"); // torna 50 de term_taxonomy_id que es de bares
$fila2 = $tid->fetch_array(MYSQLI_ASSOC);
$tid = $fila2['term_taxonomy_id'];
$tots = $db->query("SELECT * FROM wp_term_relationships WHERE term_taxonomy_id = '$tid'");
$i = 0;
while ($fila3 = $tots->fetch_array(MYSQLI_ASSOC)){
$arr[$i] = $fila3['object_id'];
$i++;
}
return $arr;
$db->close();
}
function getComparar($slug, $slug2){
$db = new connexio();
$result = array_intersect($this->getLugar($slug), $this->getBares($slug2));
$result = implode(", ", $result);
$resultat = $db->query("SELECT post_title FROM wp_posts WHERE id IN (SELECT object_id FROM wp_term_relationships WHERE object_id IN ($result))");
while ($fila4 = $resultat->fetch_array(MYSQLI_ASSOC)){
print_r($fila4['post_title']);
echo '<br/>';
}
return $result;
$db->close();
}