Selamlar wp icin php bilgisi olan arkadaşların yardımına ihtiyacım var, bir yazım için o yazıya benzeyen içerikleri listeliyorum fakat özel alandaki resim urllerini cekerek yazılarda resimli benzer içerikleri göstermek istiyorum yan yana.
resimsiz benzer yazılar kodu
Ayrıcada wordpress icin kod yardımıyla en çok okunan yazıları resimli olarak gösteren kod varmı herbirşeye eklenti kullanmaktansa bu tip kodlarla yapmak cpu tüketimini oldukca düşürüyor biliyosunuz kolay gelsin.
resimsiz benzer yazılar kodu
benzer yazıları alt alta göstermekte ben bunları 7 tane gördüğünüz üzere yanyana resimli göstermek istiyorum yardımcı olacaklara şimdiden tşk ederim.<?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, 7);
$a_title = $excerpt . "..."; ?>
<a href="<?php the_permalink(); ?>" title="<?php echo $a_title ?>"><br />
<?php if ( get_the_title() ) { the_title(); } else { echo "Benzer Yazılar Bulunamadı"; } ?></a>
<?php endforeach // $posts as $post ?>
</ul>
<?php endif // $posts ?>
<?php
$post = $this_post;
unset($this_post);
?>
</div>
Ayrıcada wordpress icin kod yardımıyla en çok okunan yazıları resimli olarak gösteren kod varmı herbirşeye eklenti kullanmaktansa bu tip kodlarla yapmak cpu tüketimini oldukca düşürüyor biliyosunuz kolay gelsin.