post->ID; $tags = wp_get_post_tags($postid); foreach($tags as $tag) { $relevantTags[] = $tag->term_id; } if ($relevantTags) { $args=array( 'tag__in' => $relevantTags, 'post__not_in' => array($postid), 'caller_get_posts'=>1 ); $my_query = new WP_Query($args); } else { $args=array( 'post__not_in' => array($postid), 'caller_get_posts'=>1 ); $my_query = new WP_Query($args); } if( $my_query->have_posts() ) { while ($my_query->have_posts()) { $my_query->the_post(); $relevantIDs[] = get_the_ID(); } } else { $relevantIDs[] = ""; } wp_reset_query(); return $relevantIDs; } /* get links by post id */ function getRelatedLinks($postID,$length = 255) { $con = DBconnect(); mysql_select_db('sofortratgeber', $con); $query1 = "SELECT post_url,keyword FROM sr_links WHERE post_id='$postID' ORDER BY priority DESC"; $result1 = mysql_query($query1); while ($row = mysql_fetch_array($result1, MYSQL_BOTH)) { if (strlen($row[1]) > $length) { $dots = "..."; } $links[] = '
'; } $randpos = rand(0,count($links)-1); mysql_close($con); return $links[$randpos]; } function getLinkList($num,$length) { $idarray = get_the_tag_ids(); foreach ($idarray as $id) { $linklist[] = getRelatedLinks($id,$length); } shuffle($linklist); if (count($linklist) > $num) { $linklist = array_slice($linklist,0,$num); } return implode("\n",$linklist); } ?> "; $allkw .= "$row2[0] "; //collect all keywords } } else { $allkw .= "$row2[0] "; //collect all keywords } } //$keywords .= "

Letzte Suchbegriffe

"; $keywords = strtolower(utf8_encode($keywords)); $frequency = getMostUsed(utf8_encode(strtolower($allkw))); asort($frequency); $frequency = array_reverse($frequency, true); $keywords .= "
Häufigste Suchbegriffe
"; for ($x = 0; ($x < sizeof($frequency)) && ($x < 10); ++$x) { $keywords .= strtolower(key($frequency))." (".current($frequency)." mal)
"; next($frequency); } mysql_close($con); return $keywords; } ?>