Mar 14
Per aggiungere post correlati nel vostro blog, copiate e incollate questo codice PHP nella pagina “single.php”.
< ?php
$original_post = $post;
$tags = wp_get_post_tags($post->ID);
if($tags)
{
echo ‘
Related Posts
‘;
$sendTags = array();
foreach($tags as $tag)
$sendTags[] = $tag->term_id;
$args = array(
‘tag__in’ => $sendTags,
‘post__not_in’ => array($post->ID),
’showposts’ => 5,
‘caller_get_posts’ => 1,
);
$queryDb = new WP_Query($args);
if($queryDb->have_posts())
{
echo ‘
- ‘;
- ">
< ?php the_title(); ?>
while ($queryDb->have_posts()) {
$queryDb->the_post();
?>
< ?php
}
echo ‘
‘;
}
}
$post = $original_post;
wp_reset_query();
?>
fonte: www.sastgroup.com » Vai al post originale