Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <h2>Related Posts</h2>
- <!-- "previous page" action -->
- <a class="prev browse left"></a>
- <?php
- $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),
- 'showposts'=>12, // get all the posts at once, then split them up afterwards.
- 'ignore_sticky_posts' => 1
- );
- $posts_per_block = 4;
- $my_query = new wp_query($args); ?>
- <!-- root element for scrollable -->
- <div class="scrollable" id=chained>
- <!-- root element for the items -->
- <div class="items">
- <?php
- if( $my_query->have_posts() ) : while ($my_query->have_posts()) : $my_query->the_post();
- if ( ($my_query->current_post) == 0 ) {
- echo '<div>';
- }
- elseif ( ( $my_query->current_post ) % $posts_per_block == 0 ) {
- echo '</div><div>'; //close and open a new div every nth post
- }
- ?>
- <div class="relatedPosts"><a href="<?php the_permalink() ?>" rel="bookmark"><?php the_post_thumbnail(array(120,80)); ?></a>
- <div class="relatedPosts_title"><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></div></div>
- <?php
- if ( ( $my_query->current_post + 1) == ( $my_query->post_count ) ) {
- echo '</div>'; //close the block if you run out of posts
- } ?>
- <?php
- endwhile; endif;
- ?>
- </div>
- <?php } // end if($tags) ?>
- </div>
- <!-- "next page" action -->
- <a class="next browse right"></a>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement