Created
April 2, 2012 01:03
-
-
Save adalbertopita/2279839 to your computer and use it in GitHub Desktop.
Wordpress: Listar posts relacionados by Tags
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?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