i got another code but
dont know how to exclude cat
function dt_related_posts($args = '') {
global $post, $news;
if ($news['related'] == 1) {
// extract args
$defaults = array(
'news_heading' => sprintf(__('More on %s','news'), dt_get_category(false)),
'photo_heading' => __('More Photo Galleries','news'),
'video_heading' => __('Watch More Videos','news'),
'showposts' => $news['related_num'],
'imagewidth' => 200,
'imageheight' => 140
);
// simplify vars
$r = wp_parse_args( $args, $defaults );
$news_heading = $r['news_heading'];
$photo_heading = $r['photo_heading'];
$video_heading = $r['video_heading'];
$showposts = $r['showposts'];
$imagewidth = $r['imagewidth'];
$imageheight = $r['imageheight'];
// get current post category ID
$CatListArray = wp_get_post_categories($post->ID);
$current_cat = $CatListArray[0];
// set current post ID to var
$current_post = $post->ID;
// get current post content type
if (get_post_meta($post->ID, 'slideshow')) $content_type = 2;
elseif (get_post_meta($post->ID, 'video')) $content_type = 3;
else $content_type = 1;
// build the relatd content query
$display = new WP_query();
if ($content_type == 1) $display->query(array('showposts' => $showposts, 'orderby' => 'rand', 'cat' => $current_cat, 'post__not_in' => array($current_post)));
if ($content_type == 2) $display->query(array('showposts' => $showposts, 'orderby' => 'rand', 'meta_key' => 'slideshow', 'post__not_in' => array($current_post)));
if ($content_type == 3) $display->query(array('showposts' => $showposts, 'orderby' => 'rand', 'meta_key' => 'video', 'post__not_in' => array($current_post)));
global $wp_query; $wp_query->in_the_loop = true;
// display results
if ($display->have_posts()) :
echo '<div class="related">';
echo '<div class="related_header">'; if ($content_type == 2) echo $photo_heading; elseif ($content_type == 3) echo $video_heading; else echo $news_heading; echo '</div>';
$i = 0; while ($display->have_posts()) : $display->the_post(); $i++;
if ($i <= 3) {
// put them in big thumbs
echo '<div class="related_big">';
dt_thumb('width='.$imagewidth.'&height='.$imageheight);
echo '<div class="related_title"><a href="'.get_permalink($post->ID).'" title="'.get_the_title().'">';
if ($content_type == 1) dt_posttype();
the_title();
echo '</a>';
if ($content_type == 2) dt_photos_number('show_tag=false');
echo '</div>';
echo '</div>';
}
if ($i == 3) echo '<div class="clear"></div><div class="related_s"></div>'; // cut after the first 3 items
if ($i == $display->post_count) echo '<div class="clear"></div>'; // if there are few posts (fix)
if ($i > 3) {
echo '<div class="related_item"><a href="'.get_permalink($post->ID).'" title="'.get_the_title().'">';
if ($content_type == 1) dt_posttype();
the_title();
echo '</a>';
if ($content_type == 2) dt_photos_number('show_tag=false&span_class=photo_count_inline');
echo '</div>';
}
endwhile;
echo '</div>';
endif;
}
// Lets kill this query
wp_reset_query();
}