Praticamente grazie alla funzione qui in basso wordpress cerca i post correlati a quello principale in base alle keyword associate al post, e in concomitanza di anche una sola keyword lui ti associa i post. Voi adesso vi chiederete cosa voglio io io vorrei che solamente quando combaciano 2 keywords lui mi associa i posts, solo che non masticando php non saprei dove mettere le mani


Codice PHP:
function GetRelatedPosts($tags$limit 0) {
        global 
$wpdb$tabletags$tablepost2tag$post$typelimitsql;

        
$now current_time('mysql'1);

        
$taglist "'" str_replace("'",'',str_replace('"','',urldecode($tags[0]->tag))). "'";
        
$tagcount count($tags);
        if (
$tagcount 1) {
            for (
$i 1$i <= $tagcount$i++) {
                
$taglist $taglist ", '" str_replace("'",'',str_replace('"','',urldecode($tags[$i]->tag))) . "'";
            }
        }

        if (
$post->ID) {
            
$notclause "AND p.ID != $post->ID";
        }

        if (
$limit != 0) {
            
$limitclause "LIMIT $limit";
        }

        
$q = <<<SQL
        SELECT DISTINCT p.*, count(p2t.post_id) as cnt
             FROM 
$tablepost2tag p2t, $tabletags t, $wpdb->posts p
             WHERE p2t.tag_id = t.tag_id
             AND p2t.post_id = p.ID
             AND (t.tag IN (
$taglist))
             AND post_date_gmt < '
$now'
             AND 
$typelimitsql
             
$notclause
             GROUP BY p2t.post_id
             ORDER BY cnt DESC, post_date_gmt DESC
             
$limitclause
SQL;

        return 
$wpdb->get_results($q);
    }