Cara memasang Artikel terkait di wordpress tanpa plugin

Cara memasang Artikel terkait di wordpress tanpa plugin
web.edikomputer.com - satu teknik Seo untuk meningkatkan jumlah pageview adalah degan menggunakan artikel terkait, dal kali ini web edikoputer akan membahas tentang cara pemasangan artikel terkait  untuk wordpress, dan ini hanya berlaku untuk wordpress.org atau wordpress self hosting bukan wordpress.com.

Cara pemasangan kali ini kita tidak menggunakan plugin dari wordpress, tetapi kita hanya menyisipkan kode pada template website kita agar menampilkan artikel terkait di setiap halaman yang kita buat sehingga user atau pengunjung bisa melihat artikel menarik lainnya untuk di baca.

Oke langsung saja saya tunjukan caranya.
login ke admin blog kamu kemudian pilih menu Appearance > Editor lalu cari file single.php karena kita akan memasang di halaman posting saja kemudian cari kode ini :
<?php include(‘templates/comments.php’); ?> atau <?php comments_template(); ?>
kemudian copy kode ini diatasnya :
Code:
<!– related posts START –>
<?php
$this_post = $post;
$category = get_the_category(); $category = $category[0];
$category = $category->cat_ID; $posts = get_posts(‘numberposts=6&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 ) : ?>
<div id="related_articles">
<h4>Artikel terkait</h4>
<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> </li>
<?php endforeach // $posts as $post ?>
</ul>
</div>
<?php endif // $posts ?>
<?php
$post = $this_post;
unset($this_post);
?>
<!– related posts END –>
Jika sudah semua save dan lihat hasilnya
Demikian Artikel tentang Cara memasang Artikel terkait di wordpress tanpa plugin yang sudah saya bahas mudah mudahan bisa dipahami dan langsung dipraktekan.
thumbnail Title: Cara memasang Artikel terkait di wordpress tanpa plugin
Posted by:admin
Rating: 4.5
Reviewer: 507User Reviews

0 comments:

Post a Comment