Skip to content

Instantly share code, notes, and snippets.

@adalbertopita
Created April 2, 2012 01:03
Show Gist options
  • Select an option

  • Save adalbertopita/2279839 to your computer and use it in GitHub Desktop.

Select an option

Save adalbertopita/2279839 to your computer and use it in GitHub Desktop.
Wordpress: Listar posts relacionados by Tags
<?php
//$post->ID = Post atual
$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'=>6,
'caller_get_posts'=>1
);
$related = new wp_query($args);
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment