Wpde okunan yazinin altina ayni kategorideki yazilari cikarma.
8
●500
- 27-07-2008, 22:48:32Arkadaslar bugun bir alanadima wordpress kurdum.Ama wpden hic anlamadigim icin bir sorunum var.Mesela Istanbul diye bir kategorim var.Misal bu kategori altinda 3 tane tarihi, turistik yerleri ve sehir plani diye yazi olsun.Simdi ben tarihi yazisi okunurken bu yazinin altina nasil diger 2 yazinin linkini siralayabilirim?Lütfen yani bir kategorideki yazi okunurken bu kategorinin diger yazilarinin linkleride altta siralansin
- 27-07-2008, 22:58:24temanızın single.php dosyasına aşağıdaki kodları ekleyin
<div class="relatedposts"> <h3>İlgili Yazılar</h3> <ul> <?php foreach ( $posts as $post ) : ?> <li><a href="<?php the_permalink() ?>" title="<?php echo trim(str_replace("\n"," ",preg_replace('#<[^>]*?>#si','',get_the_excerpt()))) ?>"><?php if ( get_the_title() ){ the_title(); }else{ echo "Untitled"; } ?></a> (<?php the_time('M d, Y') ?>)</li> <?php endforeach // $posts as $post ?> </ul> </div>
style.css dosyasınada aşağıdaki kodları ekleyin
Alıntı - 27-07-2008, 23:03:10gevv cok tesekkurler.Yalniz sadece okunan konun linki gorunuyor aceba nerede hata yapmis olabilirim.gevv adlı üyeden alıntı: mesajı görüntüle
- 27-07-2008, 23:07:46yalnışlık olmuş kusura bakma aşağıdaki kodu single.php dosyasına eklemen yeterli diğerlerini silin
<?php $this_post = $post; $category = get_the_category(); $category = $category[0]; $category = $category->cat_ID; $posts = get_posts('numberposts=5&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 ) : ?> <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 "Untitle"; } ?></a> <?php endforeach // $posts as $post ?> </ul> <?php endif // $posts ?> <?php $post = $this_post; unset($this_post); ?>
numberposts=5 değerini arttırdığınızda görünen yazı sayısı artar - 27-07-2008, 23:14:23birde ilk verdiğim css kodları ile gösterim daha iyi olabilir css dosyasına eklediğiniz kodları silmeyin yeni kodları aşağıdaki gibi ekleyinEnis adlı üyeden alıntı: mesajı görüntüle
<div class="relatedposts"> <h3>İlgili Yazılar</h3> <?php $this_post = $post; $category = get_the_category(); $category = $category[0]; $category = $category->cat_ID; $posts = get_posts('numberposts=5&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 ) : ?> <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 "Untitle"; } ?></a> <?php endforeach // $posts as $post ?> </ul> <?php endif // $posts ?> <?php $post = $this_post; unset($this_post); ?> </div>sonrasında css dosyasındaki kodlar ile oynama ekleme çıkartma ile değişik görünümler yapılabilir
numberposts=5 değerini arttırdığınızda görünen yazı sayısı artar - 27-07-2008, 23:18:45Ilgilendiginiz icin gercekten cok tesekkur ederim dediginiz gibi bu kodla daha iyi oldu.gevv adlı üyeden alıntı: mesajı görüntüle
- 28-07-2008, 06:42:26Saolasın benımde ısıme yarada başlık yok bunda ama olsun +r tesekkurlergevv adlı üyeden alıntı: mesajı görüntüle