Bir yazının altında genelde benzer yazılar bölümünde yazının bulunduğu kategorideki yazılar çıkar fakat bende son yazılar çıkıyor. Aşağıdaki kod da nasıl bir değişiklik yapmak gerekir?
<?php
$cacheB = "cacheB";
$cacheBTime = 60 * 10;
if(false === get_transient($cacheB)){
ob_start();
?>
<div class="guncelhaberler">
<div class="top2"></div>
<div class="orta">
<div class="anabas"> <p> BENZER HABERLER </p> </div>
<div class="temiz"></div>
<?php
$categories = get_the_category($post->ID);
if ($categories) {
$category_ids = array();
foreach($categories as $individual_category) $category_ids[] = $individual_category->term_id;
$args=array(
'category__in' => $category_ids,
'post__not_in' => array($post->ID),
'showposts'=>6, // Gösterilecek benzer yazı sayısı
'caller_get_posts'=>1
);
$my_query = new wp_query($args);
if( $my_query->have_posts() ) {
while ($my_query->have_posts()) {
$my_query->the_post();
?>
<div class="konu">
<div class="foto">
<?php $ozel = get_post_meta($post->ID,'ozel', true); if($ozel != "") { ?>
<div class="dal"> <? echo ($ozel); ?></div>
<?php }else{ ?>
<?php } ?>
<?php if ( has_post_thumbnail() ) { $src = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), 'full', false, '' ); $thumbnailSrc = $src[0]; ?>
<a href="<?php the_permalink() ?>" title="<?php the_title(); ?>"><img src="<?php echo bloginfo('template_url'); ?>/thumb/timthumb.php?src=<?php echo $thumbnailSrc; ?>&w=188&h=140&zc=1" width="188" height="140" alt="<?php the_title(); ?>" /></a>
<?php } else { ?>
<?php $resim = get_post_meta($post->ID,'resim', true);
if($resim != "") { ?>
<a href="<?php the_permalink() ?>" title="<?php the_title(); ?>"><img src="<? echo ($resim); ?>" width="188" height="140" alt="<?php the_title(); ?>" /></a>
<?php }else{ ?>
<a href="<?php the_permalink() ?>" title="<?php the_title(); ?>"><img src="<?php bloginfo('template_url'); ?>/images/default.jpg" width="188" height="140" alt="<?php the_title(); ?>" /> </a>
<?php } ?>
<?php }?>
<p> <a href="<?php the_permalink();?>"><?php the_title();?></a> </p>
</div>
</div> <div class="line"></div>
<?php
}
echo '</ul>';
}
wp_reset_query();
}
?>
</div>
<div class="bottom2"></div>
</div>
<?php
set_transient($cacheB, ob_get_contents(), $cacheBTime);
ob_end_flush();
}else{
echo get_transient($cacheB); }
?>