Advertisement
Guest User

Untitled

a guest
May 5th, 2015
239
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.69 KB | None | 0 0
  1. <?php
  2.  
  3. global $post;
  4. $categories = get_the_category($post->ID);
  5. if($categories) {
  6.  
  7. foreach( $categories as $individual_category ) {
  8. $category_ids[] = $individual_category->term_id;
  9. }
  10. $args = array(
  11. 'category__in' => array($category_ids),
  12. 'numberposts' => 3, /* You can change this to show more */
  13. 'post__not_in' => array($post->ID),
  14. 'post_type' => 'mirage-parties'
  15. );
  16.  
  17. $related_posts = get_posts( $args );
  18.  
  19. if($related_posts) {
  20. echo '<section class="row row--flex row--fullwidth"><div class="small-12 medium-9 medium-centered"><h2>Related Posts</h2></div>';
  21. foreach ( $related_posts as $post ) : setup_postdata( $post ); ?>
  22. <figure id="post-<?php the_ID(); ?>" <?php post_class('casestudyfigure'); ?>>
  23. <!-- post thumbnail -->
  24. <?php if ( has_post_thumbnail()) : // Check if thumbnail exists ?>
  25. <a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>">
  26. <?php the_post_thumbnail('large-size'); // Declare pixel size you need inside the array ?>
  27. </a>
  28. <?php endif; ?>
  29. <!-- /post thumbnail -->
  30.  
  31. <figcaption class="casestudyfigure__caption">
  32. <h3><?php the_title(); ?></h3>
  33. <p><?php miragewp_excerpt('miragewp_index'); ?></p>
  34. </figcaption>
  35.  
  36.  
  37. </figure>
  38. <!-- /article -->
  39. <?php endforeach; }
  40. }
  41. wp_reset_postdata();
  42. echo '</section>';
  43.  
  44. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement