Wordpress Temasına İlgili yazılar bölümü Eklemek


Yeni kullanmaya başladığım bir uygulama
bu iş için eklentiler var ama eklenti kurmak işime gelmiyor
ne kadar az eklenti o kadar az sorun
Elektronik için bir wordpress tema modifiyesi yapmıştım kaynak temadaki bu özelliği kullandığım temaya ekledim
yazılarda yorum bölümünün üstünde görmüşsünüzdür ilgili kategoride yayınlanan yazıların linkleri var ben 4 adet link olsun istedim isterseniz daha fazlasıda olabilir kodlar Wscorvette temasının comments.php dosyasında bulunuyor ben temamda single.php dosyasına ekledim en uygun bölüm orada
Orjinal kodlar
$this_post = $post;
$category = get_the_category(); $category = $category[0]; $category = $category->cat_ID;
$posts = get_posts('numberposts=4&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);
?>
üçüncü satırdaki numberposts=6 değerini yükseltirseniz daha fazla yazı linki görünür ilk denemelerimde uygun yerleşimi sağlayamadım
son olarak kodları tablo içine aldım limitide 5 olarak sınırladım sizde temanıza göre tablo kullanabilirsiniz ayrıca bu tablo olayı diğer konulardada çok işe yarıyor
mesela temamın sağ menüsünde yönetim ve istatistik bölümü yan yana duruyor bunu kodları tablo içine alarak sağladım Sağ olsun Heytbecom Abimiz wordpress forumlarında imdadıma yetişmişti
Tabla içine alınan kodlar
<td width="50%" valign="top"><?php
$this_post = $post;
$category = get_the_category(); $category = $category[0]; $category = $category->cat_ID;
$posts = get_posts('numberposts=4&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);
?>
?>
</td></tr></table>
8/05/2008 10:25 pm
ellerine sağlıkta yeni wp kullanan arkadaşlar için zor olabilir..en iyisi eklentiler diye düşünüyom
22/12/2008 5:34 pm
hiç bişe anlamadım. ekleyeceğimiz kod hangisi nerde.