Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php $orig_post = $post;
- global $post;
- $tags = wp_get_post_tags($post->ID);
- if ($tags) {
- $tag_ids = array();
- foreach($tags as $individual_tag) $tag_ids[] = $individual_tag->term_id;
- $args=array(
- 'tag__in' => $tag_ids,
- 'post__not_in' => array($post->ID),
- 'posts_per_page'=>15, // Number of related posts that will be shown.
- 'ignore_sticky_posts'=>1
- );
- $my_query = new wp_query( $args );
- if( $my_query->have_posts() ) {
- ?>
- <div class="relatedposts"><div class="relatedposts-title"><h6><?php _e('Related Posts', 'communityjunction'); ?>:</h6></div><div class="relatedposts-child">
- <?php
- while( $my_query->have_posts() ) {
- $my_query->the_post(); ?>
- <div class="blog-thumbs-view-entry">
- <div class="blog-thumb">
- <?php if ( has_post_thumbnail() ) { ?>
- <a href="<?php the_permalink(); ?>"><?php the_post_thumbnail('post-thumbnail'); ?></a>
- <?php } else { ?>
- <a href="<?php the_permalink(); ?>"><img src="<?php echo get_template_directory_uri(); ?>/images/no-thumbnail.png"></a>
- <?php } ?>
- <div class="blog-box-comments">
- <span><?php comments_number('0', '1', '%'); ?></span>
- <div class="clear"></div>
- <div class="blog-box-comments-buble"></div>
- </div>
- </div>
- <div class="blog-box-bottom">
- <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>
- </div>
- <div class="blog-box-details">
- <?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>
- </div>
- </div><!--blog-thumbs-view-entry-->
- <?php }
- echo '</div></div>';
- }
- }
- $post = $orig_post;
- wp_reset_query(); ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement