• 29-04-2015, 16:34:19
    #1
    arkadaşlar konu altında related post olarak 5-6 konu göstermek istiyorum plugin kullanamıyorum bi nedenden dolayı bunu kod ile yapmaya çalıştım ama güzel bi anlatan site bulamadım ingilizcemde biraz kıt inceledim ama hep çakıldım yardımcı olabilirseniz sevinirim
  • 29-04-2015, 16:43:56
    #2
    Yunus emre ye teşekkür edebilirsin ustad..
    bu php kodlarını single.php ye ekle , css kodlarını da style.css ye , canavar gibi çıkacak
    <!-- benzer yazılar son -->
    
    <div class="baslikblok">Benzer Yazılar</div>
     <ul class="benzerler">
     <?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'=>4, // Gösterilecek benzer yazi sayisi
          'caller_get_posts'=>1
       );
     
            $my_query = new wp_query($args);
       if( $my_query->have_posts() ) {
          while ($my_query->have_posts()) {
             $my_query->the_post();
          ?>
          
            
             <li>
    <?php if (function_exists('has_post_thumbnail')) {
     if ( has_post_thumbnail() ) { ?>
        <div class="thumb4">
        <a href="<?php the_permalink(); ?>"><?php the_post_thumbnail(); ?></a>
           <p><?php kisa_baslik(); ?></p>
        </div>
    
       <?php } } ?>
    
             </li>
             
          <?php
          }
          echo '<div class="temizle"></div>';
       }
    wp_reset_query();
    }
    ?> 
    
    <!-- benzer yazılar son -->
    css
    ul.benzerler{ float:left; margin:10px 0px 0px 10px; padding:0px;}
    ul.benzerler li{ list-style:none; float:left; padding:0px 5px 10px 5px; }
    .baslikblok{ font-weight:bold; min-height:30px; line-height:30px; font-size: 11px; margin: 0px 13px 0px 15px; padding-left:20px; color: #7e7e7e; text-decoration: none; text-shadow: 0 1px #fff; background: #f3f3f3; -webkit-box-shadow: inset 0px 0px 2px #fff; -moz-box-shadow: inset 0px 0px 2px #fff; box-shadow: inset 0px 0px 2px #fff; border: 1px solid #DFDFDF; border-radius: 5px; -moz-border-radius: 5px; -webkit-border-radius: 5px;}
  • 29-04-2015, 18:35:41
    #3
    chnyrdkl adlı üyeden alıntı: mesajı görüntüle
    Yunus emre ye teşekkür edebilirsin ustad..
    bu php kodlarını single.php ye ekle , css kodlarını da style.css ye , canavar gibi çıkacak
    <!-- benzer yazılar son -->
    
    <div class="baslikblok">Benzer Yazılar</div>
     <ul class="benzerler">
     <?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'=>4, // Gösterilecek benzer yazi sayisi
          'caller_get_posts'=>1
       );
     
            $my_query = new wp_query($args);
       if( $my_query->have_posts() ) {
          while ($my_query->have_posts()) {
             $my_query->the_post();
          ?>
          
            
             <li>
    <?php if (function_exists('has_post_thumbnail')) {
     if ( has_post_thumbnail() ) { ?>
        <div class="thumb4">
        <a href="<?php the_permalink(); ?>"><?php the_post_thumbnail(); ?></a>
           <p><?php kisa_baslik(); ?></p>
        </div>
    
       <?php } } ?>
    
             </li>
             
          <?php
          }
          echo '<div class="temizle"></div>';
       }
    wp_reset_query();
    }
    ?> 
    
    <!-- benzer yazılar son -->
    css
    ul.benzerler{ float:left; margin:10px 0px 0px 10px; padding:0px;}
    ul.benzerler li{ list-style:none; float:left; padding:0px 5px 10px 5px; }
    .baslikblok{ font-weight:bold; min-height:30px; line-height:30px; font-size: 11px; margin: 0px 13px 0px 15px; padding-left:20px; color: #7e7e7e; text-decoration: none; text-shadow: 0 1px #fff; background: #f3f3f3; -webkit-box-shadow: inset 0px 0px 2px #fff; -moz-box-shadow: inset 0px 0px 2px #fff; box-shadow: inset 0px 0px 2px #fff; border: 1px solid #DFDFDF; border-radius: 5px; -moz-border-radius: 5px; -webkit-border-radius: 5px;}
    Fatal error: Call to undefined function kisa_baslik() in hocam şöyle bi hata verdi nasıl düzeltebilirim
  • 29-04-2015, 18:37:04
    #4
    bantumi adlı üyeden alıntı: mesajı görüntüle
    Fatal error: Call to undefined function kisa_baslik() in hocam şöyle bi hata verdi nasıl düzeltebilirim
    function kisa_baslik() {
    $kisa_baslik = get_the_title();
    if(strlen($kisa_baslik)> 20) {
    $kisa_baslik = mb_substr($kisa_baslik, 0, 30) . '..';
    }
    echo $kisa_baslik;
    }

    şu kısımı functions.php ye ekleyip denermsiiniz?
    olmazsa skype den yardım edeyim , team ile.
  • 29-04-2015, 18:46:02
    #5
    chnyrdkl adlı üyeden alıntı: mesajı görüntüle
    function kisa_baslik() {
    $kisa_baslik = get_the_title();
    if(strlen($kisa_baslik)> 20) {
    $kisa_baslik = mb_substr($kisa_baslik, 0, 30) . '..';
    }
    echo $kisa_baslik;
    }

    şu kısımı functions.php ye ekleyip denermsiiniz?
    olmazsa skype den yardım edeyim , team ile.
    hallettim hocam çok teşekkürler allah razı olsun
  • 29-04-2015, 18:51:26
    #6
    bantumi adlı üyeden alıntı: mesajı görüntüle
    hallettim hocam çok teşekkürler allah razı olsun
    rica ederim hocam.