• 19-09-2008, 00:58:20
    #1
    Merhaba

    wordpress sitemin içinde eklentisiz sadece kodla çalışan Benzer Yazılar var related-post.php Şuanda konu içinde altta 5 tane benzer başlık sıralanıyor bunu 40,50 nasıl yapabilirim oynadım fakat işin içinden çıkamadım.

    <?php
    $this_post = $post;
    $category = get_the_category(); $category = $category[0]; $category = $category->cat_ID;
    $posts = get_posts('numberposts=6&offset=0&orderby=post_date&order=DESC&category='.$category);
    $count = 0;
    foreach ( $posts as $post ) {
    if ( $post->ID == $this_post->ID || $count == 5) {
    unset($posts[$count]);
    }else{
    $count ++;
    }
    }
    ?>
    <?php if ( $posts ) : ?>
    <div class="post-content">
    <h3>Benzer Yazılar</h3>
    <ul>
    <?php function getWords($text, $limit) {
    $array = explode(" ", $text, $limit +1);
    if(count($array) > $limit) {
    unset($array[$limit]);
    }
    return implode(" ", $array); }
    ?>
    <?php foreach ( $posts as $post ) : ?>
    <?php $mycontent = strip_tags($post->post_content);
    $excerpt = getWords($mycontent, 15);
    $a_title = $excerpt . "..."; ?>
    <li><a href="<?php the_permalink(); ?>" title="<?php echo $a_title ?>">
    <?php if ( get_the_title() ) { the_title(); } else { echo "Başlıksız"; } ?></a>
    (<?php the_time('d F Y') ?>)
    </li>
    <?php endforeach // $posts as $post ?>
    </ul>
    </div>
    <?php else : ?>
    <div class="post-content">
    <h3>Benzer Yazılar</h3>
    <ul>
    <li>Benzer Yazı Bulunamadı</li>
    </ul>
    </div>
    <?php endif // $posts ?>
    <?php
    $post = $this_post;
    unset($this_post);
    ?>
  • 19-09-2008, 01:12:36
    #2
    $posts = get_posts('numberposts=6&offset=0&orderby=post_dat e&order=DESC&category='.$category);
    Bu satırda;

    numberposts= burayı değiştir 16 yap mesela
  • 19-09-2008, 03:18:08
    #3
    teşekkürler varistam sağolasın hocam

    orjinalinda 5 taneydi bende ha bire 5 diye aratiyordum
  • 19-09-2008, 11:31:50
    #4
    Simple tags eklentisinde benzer yazılar otomatik geliyor ve benzer yazılar için istediğin ölçüyü verebiliyorsun
  • 19-09-2008, 14:14:12
    #5
    Bunu biliyorum simple tags eklentisi kurulu lakin sadece o bölümü deaktif, çünkü bir sebebi var