• 12-03-2013, 11:39:25
    #1
    Merhaba arkadaşlar. Elimde bulunan koda göre sitemi ayarlamıştım ama ben bunun sadece kategorilere göre gösterim yapmasını istiyorum. Bunu nasıl sağlayabilirim?
    <?php
    $args = array( 'numberposts' => 4, 'order'=> 'desc', 'orderby' => 'rand' );
    $merakliyazar = get_posts( $args );
    foreach ($merakliyazar as $post) : setup_postdata($post); ?>
    <li>
    <a href="<?php the_permalink(); ?>" />
    <p>
    <?php if ( has_post_thumbnail() ) { the_post_thumbnail(array(135,120), array('class' => 'b_resim')); } else { ?>
    <img src="<?php echo bloginfo("template_url"); ?>/img/merakliyazar.png" alt="<?php the_title(); ?>" title="<?php the_title('10'); ?>" width="140px" height="140px" />
    <?php } ?>
    </p>
    <span>
    <?php the_title(); ?>
    </span>
    </a>
    </li>
    <?php endforeach; wp_reset_query(); ?>
    Kategoriler için farklı benzer yazılar kodları var ama bunun tasarımını ben bu kodlara göre ayarlamıştım.
  • 12-03-2013, 13:15:27
    #2
    Alıntı
    Elimde bulunan koda göre sitemi ayarlamıştım ama ben bunun sadece kategorilere göre gösterim yapmasını istiyorum. Bunu nasıl sağlayabilirim?
    Sizin bu kodunuz benzer yazılar değil rastgele 4 yazıyı göster kodu...

    AAA yazısı şayet Komik Yazılar kategorisinde ise ve
    BBB yazısı da Komik Yazılar kategorisinde ise ;

    AAA yazısının bulunduğu sayfada Benzer yazılar bölümünde BBB yazısınıda görebilirsiniz...

    Alıntı
    <?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'=>10, // Number of related posts that will be shown.

    'caller_get_posts'=>1

    );

    $my_query = new wp_query($args);

    if( $my_query->have_posts() ) {
    echo '';
    while ($my_query->have_posts()) {

    $my_query->the_post();

    ?>
  • 12-03-2013, 13:39:05
    #3
    haXan1711 adlı üyeden alıntı: mesajı görüntüle
    Sizin bu kodunuz benzer yazılar değil rastgele 4 yazıyı göster kodu...

    AAA yazısı şayet Komik Yazılar kategorisinde ise ve
    BBB yazısı da Komik Yazılar kategorisinde ise ;

    AAA yazısının bulunduğu sayfada Benzer yazılar bölümünde BBB yazısınıda görebilirsiniz...
    Aynen dediğiniz gibi hocam sizin dediğiniz kodla benim sitemdeki belirttiğim kodu değiştirsem sorunum çözülür değil mi?
  • 12-03-2013, 14:04:11
    #4
    Alıntı
    <li>
    <a href="<?php the_permalink(); ?>" />
    <p>
    <?php if ( has_post_thumbnail() ) { the_post_thumbnail(array(135,120), array('class' => 'b_resim')); } else { ?>
    <img src="<?php echo bloginfo("template_url"); ?>/img/merakliyazar.png" alt="<?php the_title(); ?>" title="<?php the_title('10'); ?>" width="140px" height="140px" />
    <?php } ?>
    </p>
    <span>
    <?php the_title(); ?>
    </span>
    </a>
    </li>
    <?php endforeach; wp_reset_query(); ?>
    Benim yazdıklarımın altına bu kodu eklerseniz göstermesi gerekiyor..

    Şablonunuz temanız nasıl bilmiyorum fakat bunlar çalışan kodlar...
    Sizde olmazsa single.php'nin düzenlemesi lazımdır...
  • 12-03-2013, 16:07:44
    #5
    haXan1711 adlı üyeden alıntı: mesajı görüntüle
    Benim yazdıklarımın altına bu kodu eklerseniz göstermesi gerekiyor..

    Şablonunuz temanız nasıl bilmiyorum fakat bunlar çalışan kodlar...
    Sizde olmazsa single.php'nin düzenlemesi lazımdır...
    Ne yazık ki hata veriyor hocam.
  • 12-03-2013, 20:25:37
    #6
    Temanızın içindeki single.php'nin içeriğini kopyalayıp buraya yapıştırın yardımcı olayım...
  • 12-03-2013, 20:32:34
    #7
    haXan1711 adlı üyeden alıntı: mesajı görüntüle
    Temanızın içindeki single.php'nin içeriğini kopyalayıp buraya yapıştırın yardımcı olayım...
    Alıntı
    <?php get_header(); ?>
    <div id="content" style="margin: 0px 0px 0px 0px;">
    <div id="benzer-yazilar">
    <strong> Konumunuz: <a href="http://androidsistem.net" title="Anasayfa">Anasayfa</a> > <?php the_category(' '); ?> > <a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><?php echo kisa_baslik('...', 60); ?></a> </strong>
    </div>
    <?php include (TEMPLATEPATH . "/sidebar1.php"); ?>
    <div id="content-left">
    <?php if(have_posts()):while(have_posts()):the_post(); ?>
    <div class="text">



    <h1 title="<?php the_title(); ?>"><?php the_title(); ?></h1>
    <div class="text-data">
    <strong>Yazar: </strong> <?php the_author(); ?>&nbsp; <strong>Tarih</strong> : <?php the_time('j'); ?> <?php the_time('F'); ?> <?php the_time('Y'); ?>
    <div class="comment-img"><?php comments_popup_link('0 Yorum','1 Yorum','% Yorum'); ?></a></div>
    </div>
    <div class="content-border"></div>
    <div class="text-content">
    <div class="yaziicireklam">
    Adsenseee
    </div>
    <?php the_content(''); ?>
    </div>
    <div class="bottom-data">
    <div class="kategori"><?php the_category(', '); ?></div>
    <div class="more"></div>
    </div>
    </div>
    <div align="center" id="benzer-yazilar">
    Adsenseeeeeeeeeee
    </script>
    </div>
    <?php if (!function_exists('dynamic_sidebar') || !dynamic_sidebar('Karşılaştırma Eklentisi') ) : ?>
    <h3 class="karsilastirici">Bileşenler</h3>
    <div class="karsilastir">
    <p>Bu kısım, bileşenleri eklediğiniz takdirde ortadan kalkacaktır.</p>
    </div>
    <?php endif; ?>
    <div align="center" id="benzer-yazilar">
    Adsense!!!
    </script>
    </div>
    <div class="fb-like" data-href="<?php the_permalink(); ?>" data-send="true" data-width="600" data-show-faces="false" data-font="arial"></div>

    <div class="text-tag">
    <?php the_tags('<b>Etiketler:</b> ',', '); ?>
    </div>

    <div id="MerakliYazilar">
    <h3 id="MerakliBaslik">Benzer Yazılarımız</h3>
    <ul>
    <?php
    $args = array( 'numberposts' => 4, 'order'=> 'desc', 'orderby' => 'rand' );
    $merakliyazar = get_posts( $args );
    foreach ($merakliyazar as $post) : setup_postdata($post); ?>
    <li>
    <a href="<?php the_permalink(); ?>" />
    <p>
    <?php if ( has_post_thumbnail() ) { the_post_thumbnail(array(135,120), array('class' => 'b_resim')); } else { ?>
    <img src="<?php echo bloginfo("template_url"); ?>/img/merakliyazar.png" alt="<?php the_title(); ?>" title="<?php the_title('10'); ?>" width="140px" height="140px" />
    <?php } ?>
    </p>
    <span>
    <?php the_title(); ?>
    </span>
    </a>
    </li>
    <?php endforeach; wp_reset_query(); ?>



    </ul>
    </div>
    </div>


    <div id="comments">
    <?php comments_template(); ?>
    </div>
    <?php endwhile; ?>
    <?php endif; ?>
    </div>
    </div>
    <?php get_footer(); ?>
    Çok teşekkürler hocam.
  • 13-03-2013, 11:36:06
    #8
    Alıntı
    <?php get_header(); ?>
    <div id="content" style="margin: 0px 0px 0px 0px;">
    <div id="benzer-yazilar">

    </div>
    <?php include (TEMPLATEPATH . "/sidebar1.php"); ?>
    <div id="content-left">
    <?php if(have_posts()):while(have_posts()):the_post(); ?>
    <div class="text">



    <h1 title="<?php the_title(); ?>"><?php the_title(); ?></h1>
    <div class="text-data">
    <strong>Yazar: </strong> <?php the_author(); ?>&nbsp; <strong>Tarih</strong> : <?php the_time('j'); ?> <?php the_time('F'); ?> <?php the_time('Y'); ?>
    <div class="comment-img"><?php comments_popup_link('0 Yorum','1 Yorum','% Yorum'); ?></a></div>
    </div>
    <div class="content-border"></div>
    <div class="text-content">
    <div class="yaziicireklam">
    Adsenseee
    </div>
    <?php the_content(''); ?>
    </div>
    <div class="bottom-data">
    <div class="kategori"><?php the_category(', '); ?></div>
    <div class="more"></div>
    </div>
    </div>
    <div align="center" id="benzer-yazilar">
    Adsenseeeeeeeeeee
    </script>
    </div>
    <?php if (!function_exists('dynamic_sidebar') || !dynamic_sidebar('Karşılaştırma Eklentisi') ) : ?>
    <h3 class="karsilastirici">Bileşenler</h3>
    <div class="karsilastir">
    <p>Bu kısım, bileşenleri eklediğiniz takdirde ortadan kalkacaktır.</p>
    </div>
    <?php endif; ?>
    <div align="center" id="benzer-yazilar">
    Adsense!!!
    </script>
    </div>
    <div class="fb-like" data-href="<?php the_permalink(); ?>" data-send="true" data-width="600" data-show-faces="false" data-font="arial"></div>

    <div class="text-tag">
    <?php the_tags('<b>Etiketler:</b> ',', '); ?>
    </div>

    <div id="MerakliYazilar">
    <h3 id="MerakliBaslik">Benzer Yazılarımız</h3>
    <ul>
    <?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'=>10, // Number of related posts that will be shown.

    'caller_get_posts'=>1

    );

    $my_query = new wp_query($args);

    if( $my_query->have_posts() ) {
    echo '';
    while ($my_query->have_posts()) {

    $my_query->the_post();

    ?>
    <li>
    <a href="<?php the_permalink(); ?>" />
    <p>
    <?php if ( has_post_thumbnail() ) { the_post_thumbnail(array(135,120), array('class' => 'b_resim')); } else { ?>
    <img src="<?php echo bloginfo("template_url"); ?>/img/merakliyazar.png" alt="<?php the_title(); ?>" title="<?php the_title('10'); ?>" width="140px" height="140px" />
    <?php } ?>
    </p>
    <span>
    <?php the_title(); ?>
    </span>
    </a>
    </li>


    <?php

    }

    echo '';

    }

    }

    ?>


    </ul>
    </div>
    </div>


    <div id="comments">
    <?php comments_template(); ?>
    </div>
    <?php endwhile; ?>
    <?php endif; ?>
    </div>
    </div>
    <?php get_footer(); ?>
    Bunu deneyin...
  • 13-03-2013, 21:44:44
    #9
    haXan1711 adlı üyeden alıntı: mesajı görüntüle
    Bunu deneyin...
    Ellerinize sağlık hocam gerçekten oldu