1. <?php get_header(); ?>
  2. <?php
  3. $categories = get_the_category($post->ID);
  4. if ($categories) {
  5. $category_ids = array();
  6. foreach($categories as $individual_category) $category_ids[] = $individual_category->term_id;
  7. $args=array(
  8. 'category__in' => $category_ids,
  9. 'post__not_in' => array($post->ID),
  10. 'showposts'=>5, // Number of related posts that will be shown.
  11. 'caller_get_posts'=>1
  12. );
  13. $rp_query = new wp_query($args);
  14. }
  15. ?>
  16. <div id="content">
  17. <?php if (have_posts()) : while (have_posts()) : the_post(); ?>
  18. <?php the_title('<h4>', '</h4>'); ?>
  19. <div class="postmeta">Publicado por
  20. <?php the_author_posts_link(); ?>
  21. el <?php the_time('d M, Y') ?>
  22. <div class="addthis_toolbox addthis_default_style" style="margin-top:8px;">
  23. <a class="addthis_button_facebook_like" fb:like:width="100" fb:like:layout="button_count"></a>
  24. <a class="addthis_button_tweet"></a>
  25. <a class="addthis_button_google_plusone" g:plusone:size="medium"></a>
  26. </div>
  27. <script type="text/javascript" src="http://s7.addthis.com/js/250/addthis_widget.js#pubid=xa-4e67489c228c415c"></script>
  28. </div>
  29. <div class="entry">
  30. <?php the_content(); ?>
  31. <div class="clear"></div>
  32. </div>
  33. <?php
  34. if( $rp_query->have_posts() ) {
  35. echo '<h3>Related Posts</h3><ul>';
  36. while ($rp_query->have_posts()) {
  37. $rp_query->the_post();
  38. ?>
  39. <li><?php the_post_thumbnail( thumbnail ); ?><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></li>
  40. <?php
  41. }
  42. echo '</ul>';
  43. }
  44. ?>
  45. <?php comments_template(); ?>
  46. <?php endwhile; else: ?>
  47. <?php endif; ?>
  48. </div>
  49. <?php get_sidebar(); ?>
  50. <?php get_footer(); ?>