Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <div class="thumbnails container_24">
- <!-- loop in thumbnails for the relevant category -->
- <?php
- // put all the category IDs of current post into an array
- $categories = get_the_category( $post->ID );
- $category_id_array = array();
- foreach ( $categories as $category ) {
- $category_id_array[] = $category->cat_ID;
- }
- // define how many thumbnails to show (at most)
- $thumbnail_max = 6;
- // grab all posts in the same categories as the current post
- $category_thumb_args = array( 'category__in' => $category_id_array, 'posts_per_page => $thumbnail_max', 'exclude' => $post->ID );
- $category_thumb_query = new WP_Query( $category_thumb_args );
- // if there are posts loop through them
- if ( $category_thumb_query->have_posts() ) :
- while($category_thumb_query->have_posts()) : $category_thumb_query->the_post(); ?>
- <?php if ( has_post_thumbnail() ) :?>
- <div class="grid_8 newsbox">
- <div class="news-thumbnail"><?php the_post_thumbnail(); ?></div>
- <div class="news-description">
- <a class="news-link" href="<?php the_permalink() ?>" rel="<?php the_ID(); ?>" title="Nyhet - <?php the_title_attribute(); ?>">
- <?php the_title('<p class="news-titel">', '</p>'); ?>
- <div class="news-excerpt"><?php the_excerpt(); ?></div>
- <p class="news-date"><?php the_time('F j, Y'); ?></p>
- </a>
- </div> <!-- end newsdescripton -->
- <div class="news-tag"></div>
- </div> <!-- end newsbox -->
- <?php endif;
- endwhile;
- endif;
- // reset the query since we used the_post()
- wp_reset_query();
- ?>
- <!-- stop looping in thumbnails -->
- </div> <!-- end thumbnails -->
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement