Advertisement
Guest User

Untitled

a guest
Jun 29th, 2018
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.98 KB | None | 0 0
  1. <?php $orig_post = $post;
  2. global $post;
  3. $tags = wp_get_post_tags($post->ID);
  4. if ($tags) {
  5. $tag_ids = array();
  6. foreach($tags as $individual_tag) $tag_ids[] = $individual_tag->term_id;
  7. $args=array(
  8. 'tag__in' => $tag_ids,
  9. 'post__not_in' => array($post->ID),
  10. 'posts_per_page'=>15, // Number of related posts that will be shown.
  11. 'ignore_sticky_posts'=>1
  12. );
  13. $my_query = new wp_query( $args );
  14. if( $my_query->have_posts() ) {
  15. ?>
  16.  
  17. <div class="relatedposts"><div class="relatedposts-title"><h6><?php _e('Related Posts', 'communityjunction'); ?>:</h6></div><div class="relatedposts-child">
  18.  
  19. <?php
  20. while( $my_query->have_posts() ) {
  21. $my_query->the_post(); ?>
  22.  
  23.  
  24. <div class="blog-thumbs-view-entry">
  25. <div class="blog-thumb">
  26.  
  27. <?php if ( has_post_thumbnail() ) { ?>
  28. <a href="<?php the_permalink(); ?>"><?php the_post_thumbnail('post-thumbnail'); ?></a>
  29. <?php } else { ?>
  30. <a href="<?php the_permalink(); ?>"><img src="<?php echo get_template_directory_uri(); ?>/images/no-thumbnail.png"></a>
  31. <?php } ?>
  32.  
  33. <div class="blog-box-comments">
  34. <span><?php comments_number('0', '1', '%'); ?></span>
  35. <div class="clear"></div>
  36. <div class="blog-box-comments-buble"></div>
  37. </div>
  38. </div>
  39. <div class="blog-box-bottom">
  40. <div class="blog-thumb-title"><a href="<?php the_permalink(); ?>"><?php $thetitle = get_the_title(); $getlength = strlen($thetitle); $thelength = 57; echo mb_substr($thetitle, 0, $thelength, 'UTF-8'); if ($getlength > $thelength) echo "..."; ?></a></div>
  41. </div>
  42.  
  43. <div class="blog-box-details">
  44. <?php the_category(', ') ?>, <span class="blog-box-time"><?php printf( _x( '%s ago', '%s = human-readable time difference', 'communityjunction' ), human_time_diff( get_the_time( 'U' ), current_time( 'timestamp' ) ) ); ?></span>
  45. </div>
  46.  
  47. </div><!--blog-thumbs-view-entry-->
  48.  
  49.  
  50. <?php }
  51. echo '</div></div>';
  52. }
  53. }
  54. $post = $orig_post;
  55. wp_reset_query(); ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement