Recent Posts
None | 12 sec ago
JavaScript | 12 sec ago
XML | 1 min ago
Bash | 1 min ago
XML | 2 min ago
None | 2 min ago
C | 2 min ago
None | 2 min ago
Lua | 2 min ago
PAWN | 2 min ago
Sitereport
Find cool info about any domain on the internet?
visit sitereport
Free Subdomains
Want a pastebin.com sub-domain for your community?
learn more...
What is pastebin?
Pastebin is a website that hosts all your text & code on dedicated servers for easy sharing.
learn more...
Learn a little bit about the new Pastebin.com on our help page. hide message
By kuld33p on the 4th of Jul 2009 09:32:59 PM Download | Raw | Embed | Report
  1. <div class="entry page">
  2.                 <h2>Related Posts</h2>
  3.        
  4.                 <?php
  5. //for use in the loop, list 5 post titles related to first tag on current post
  6. $tags = wp_get_post_tags($post->ID);
  7. if ($tags) {
  8.   $first_tag = $tags[0]->term_id;
  9.   $args=array(
  10.     'tag__in' => array($first_tag),
  11.     'post__not_in' => array($post->ID),
  12.     'showposts'=>5,
  13.     'caller_get_posts'=>1
  14.    );
  15.   $my_query = new WP_Query($args);
  16.   if( $my_query->have_posts() ) {
  17.     while ($my_query->have_posts()) : $my_query->the_post(); ?>
  18.       <p><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></p>
  19.       <?php
  20.     endwhile;
  21.   }
  22. }
  23. ?>
  24. </div>
Submit a correction or amendment below. Make A New Post
To highlight particular lines, prefix each line with @h@
Syntax highlighting:
Post expiration:
Post exposure:
Name / Title:
Email: