Advertisement
Guest User

Untitled

a guest
Dec 20th, 2012
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.50 KB | None | 0 0
  1. // Related Post
  2. function get_related_posts($post_id, $tags = array()) {
  3. $query = new WP_Query();
  4.  
  5. $post_types = get_post_types();
  6. unset($post_types['page'], $post_types['attachment'], $post_types['revision'], $post_types['nav_menu_item']);
  7.  
  8. if($tags) {
  9. foreach($tags as $tag) {
  10. $tagsA[] = $tag->term_id;
  11. }
  12. }
  13. $query = new WP_Query( array('showposts' => 4,'post_type' => $post_types,'post__not_in' => array($post_id),'tag__in' => $tagsA,'ignore_sticky_posts' => 1,
  14. ));
  15. return $query;
  16. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement