bdbrown

Modified Related Posts

Mar 25th, 2016
225
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.83 KB | None | 0 0
  1. <!-- Modified to create post rows to control number of posts -->
  2.  
  3. <?php $related = alx_related_posts(); ?>
  4.  
  5. <?php if ( $related->have_posts() ): ?>
  6.  
  7. <h4 class="heading">
  8.     <i class="fa fa-hand-o-right"></i><?php _e('You may also like...','hueman'); ?>
  9. </h4>
  10.  
  11. <ul class="related-posts group">
  12.  
  13. <!-- ====================================================== -->
  14. <!--  Initialize post counter; set up the post row          -->
  15. <?php $i = 1; echo '<div class="post-row">'; ?>
  16. <!-- ====================================================== -->
  17.    
  18.     <?php while ( $related->have_posts() ) : $related->the_post(); ?>
  19.     <li class="related post-hover">
  20.         <article <?php post_class(); ?>>
  21.  
  22.             <div class="post-thumbnail">
  23.                 <a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>">
  24.                     <?php if ( has_post_thumbnail() ): ?>
  25.                         <?php the_post_thumbnail('thumb-medium'); ?>
  26.                     <?php elseif ( ot_get_option('placeholder') != 'off' ): ?>
  27.                         <img src="<?php echo get_template_directory_uri(); ?>/img/thumb-medium.png" alt="<?php the_title(); ?>" />
  28.                     <?php endif; ?>
  29.                     <?php if ( has_post_format('video') && !is_sticky() ) echo'<span class="thumb-icon small"><i class="fa fa-play"></i></span>'; ?>
  30.                     <?php if ( has_post_format('audio') && !is_sticky() ) echo'<span class="thumb-icon small"><i class="fa fa-volume-up"></i></span>'; ?>
  31.                     <?php if ( is_sticky() ) echo'<span class="thumb-icon small"><i class="fa fa-star"></i></span>'; ?>
  32.                 </a>
  33.                 <?php if ( comments_open() && ( ot_get_option( 'comment-count' ) != 'off' ) ): ?>
  34.                     <a class="post-comments" href="<?php comments_link(); ?>"><span><i class="fa fa-comments-o"></i><?php comments_number( '0', '1', '%' ); ?></span></a>
  35.                 <?php endif; ?>
  36.             </div><!--/.post-thumbnail-->
  37.            
  38.             <div class="related-inner">
  39.                
  40.                 <h4 class="post-title">
  41.                     <a href="<?php the_permalink(); ?>" rel="bookmark" title="<?php the_title(); ?>"><?php the_title(); ?></a>
  42.                 </h4><!--/.post-title-->
  43.                
  44.                 <div class="post-meta group">
  45.                     <p class="post-date"><?php the_time('j M, Y'); ?></p>
  46.                 </div><!--/.post-meta-->
  47.            
  48.             </div><!--/.related-inner-->
  49.  
  50.         </article>
  51.     </li><!--/.related-->
  52.  
  53. <!-- ====================================================== -->
  54. <!--  If displayed 3 posts, close row and start new row     -->
  55. <!--  Increment post counter                                -->
  56. <?php if($i % 3 == 0) { echo '</div><div class="post-row">'; } $i++; ?>
  57. <!-- ====================================================== -->
  58.    
  59.     <?php endwhile; ?>
  60.    
  61. <!-- ====================================================== -->
  62. <!--  Close last post row                                   -->
  63. <?php echo '</div>'; ?>
  64. <!-- ====================================================== -->
  65.  
  66.     <?php wp_reset_postdata(); ?>
  67.  
  68. </ul><!--/.post-related-->
  69. <?php endif; ?>
  70.  
  71. <?php wp_reset_query(); ?>
Advertisement
Add Comment
Please, Sign In to add comment