Das muss in die single.php:
Ähnliche Beiträge:
Das muss in die functions.php:
// related post with wordpress-tags
// wordpress > 2.3
function fbbl_get_related_posts() {
global $wpdb, $post;
$now = current_time('mysql', 1);
$tags = wp_get_post_tags($post->ID);
$taglist = "'" . str_replace("'", '', str_replace('"', '', urldecode($tags[0]->term_id))). "'";
$tagcount = count($tags);
if ( $tagcount > 1 ) {
for ($i = 1; $i <= $tagcount; $i++) {
$taglist = $taglist . ", '" . str_replace("'", '', str_replace('"', '', urldecode($tags[$i]->term_id))) . "'";
}
}
$q = "SELECT DISTINCT p.*, count(t_r.object_id) as cnt FROM $wpdb->term_taxonomy t_t, $wpdb->term_relationships t_r, $wpdb->posts p WHERE t_t.taxonomy ='post_tag' AND t_t.term_taxonomy_id = t_r.term_taxonomy_id AND t_r.object_id = p.ID AND (t_t.term_id IN ($taglist)) AND p.ID != $post->ID AND p.post_status = 'publish' AND p.post_date_gmt < '$now' GROUP BY t_r.object_id ORDER BY cnt DESC, p.post_date_gmt DESC LIMIT 5;";
return $wpdb->get_results($q);
}
function fbbl_related_posts(){
if ( function_exists('get_the_tags') && (get_the_tags()) ) {
$related_posts = fbbl_get_related_posts() ;
}
if ( $related_posts ) {
foreach ($related_posts as $related_post ) {
$related_post_output = '';
$related_post_output = $related_post_output . '' . wptexturize($related_post->post_title) . '';
$related_post_output = $related_post_output . '';
echo $related_post_output;
}
} else {
echo '' . __('Keine ähnlichen Beiträge') . '';
}
}
?>