This week only. Pastebin PRO Accounts Christmas Special! Don't miss out!Want more features on Pastebin? Sign Up, it's FREE!

Untitled

By: hattendesign on May 22nd, 2012  |  syntax: None  |  size: 0.74 KB  |  views: 42  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. <?
  2. $backup = $post;
  3. $tags = wp_get_post_tags($post->ID);
  4. $tagIDs = array();
  5. if ($tags) {
  6.                 $tagcount = count($tags);
  7.                 for ($i = 0; $i < $tagcount; $i++)
  8.                         {
  9.                         $tagIDs[$i] = $tags[$i]->term_id;
  10.                         }
  11.  
  12.  $args=array( 'tag__in' => $tagIDs,'post__not_in' => array($post->ID), 'showposts'=>5, 'caller_get_posts'=>1);
  13.  $my_query = new WP_Query($args);
  14.  if( $my_query->have_posts() )
  15.                                         {
  16.                                         while ($my_query->have_posts()) : $my_query->the_post(); ?>
  17.                                         <h3><a href="<?php the_permalink() ?>" rel="bookmark" title="<?php the_title(); ?>"><?php the_title(); ?></a></h3>
  18.                                         <?   endwhile;
  19.                                         }
  20.                         }
  21. else { ?>
  22. <h2>No related trailers found!</h2>
  23.  <?php }
  24.  
  25.  $post = $backup;
  26.   wp_reset_query();
  27.  ?>
clone this paste RAW Paste Data