Sebagai blogger, om juga tentu saja masih belajar, untuk itu om mau memberikan tips-tips juga untuk membuat associated post pada wordpress tanpa plugin. sebenarnya, membuat associated post ini apa untungnya sih om?? banyak bangets untungnya loh, salah satunya adalah kita mengurangi plugin yang ada di wordpress dan kalau kita kurangi, maka kita ini telah meringankan reload blog kita. Oke, masih semngats ngeblog kan?? kalo masih, coba tempelkan scrift dibawah ini, caranya si silahkan masuk ke themenya, stelah masuk theme, silahkan tempelkan saja dimana saja anda mau menempelkannya. om sih lebih suka di single.php
Script 1,
<?php
.. ..
$tags = wp_get_post_tags($post->ID);
if ($tags) {
$tag_ids = array();
foreach($tags as $individual_tag) $tag_ids[] = $individual_tag->term_id;
$args=array(
‘tag__in’ => $tag_ids,
‘post__not_in’ => array($post->ID),
‘showposts’=>5, // Number of associated posts which will be shown.
‘caller_get_posts’=>1
);
$my_query = brand brand new wp_query($args);
if( $my_query->have_posts() ) {
echo ‘<h3>Related Posts</h3><ul>’;
while ($my_query->have_posts()) {
$my_query->the_post();
?>
<li><a href=”<?php the_permalink() ?>” rel=”bookmark” title=”Permanent Link to <?php the_title_attribute(); ?>”><?php the_title(); ?></a></li>
<?php
}
echo ‘</ul>’;
}
}
?>
Script ke 2
< ?php
//for make use of in a loop, list 5 post titles associated to initial tab upon stream post
$tags = wp_get_post_tags($post->ID);
if ($tags) {
echo ‘Related Tag Posts’;
$first_tag = $tags[0]->term_id;
$args=array(
‘tag__in’ => array($first_tag),
‘post__not_in’ => array($post->ID),
‘showposts’=>5,
‘caller_get_posts’=>1
);
$my_query = brand brand new WP_Query($args);
if( $my_query->have_posts() ) {
while ($my_query->have_posts()) : $my_query->the_post(); ?>
Script Ketiga
<?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’=>5, // Number of associated posts which will be shown.
‘caller_get_posts’=>1
);?>
Silahkan, tinggal pilih saja dari ketiga cara tersebut. semoga bermanfaat tulisan om ini ya?? heheee
.. ..





