Advertisement
jegtheme

post-related.php

Aug 7th, 2015
228
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.97 KB | None | 0 0
  1. <?php
  2.  
  3.     if(vp_option('joption.related_type') === 'yarpp') {
  4.         if(function_exists('related_posts')) {
  5.             related_posts();
  6.         } else {
  7. ?>
  8.             <section id="related-post" class="post-three-columns post-columns section">
  9.                 <h1>To use YARPP integration, please visit : <a href="http://support.jegtheme.com/documentation/related-post-yarpp/">this link</a></h1>
  10.             </section>
  11. <?php
  12.         }
  13.  
  14.     } else {
  15.  
  16.         if ( has_category() ) :
  17.             $categories = get_the_category();
  18.             $category_ids = array();
  19.             foreach( $categories as $individual_category ) $category_ids[] = $individual_category->term_id;
  20.  
  21.             $args = array(
  22.                 'category__in'        => $category_ids,
  23.                 'showposts'           => 6,
  24.                 'ignore_sticky_posts' => 1,
  25.                 'post__not_in'        => array(get_the_ID())
  26.             );
  27.  
  28.             // The Query
  29.             $the_query = new WP_Query( $args );
  30.             if ( $the_query->have_posts() ) :
  31. ?>
  32.  
  33. <section id="related-post" class="post-three-columns post-columns section">
  34.     <div class="row clearfix">
  35.  
  36.         <div class="col-md-12 section-heading-wrapper">
  37.             <h3 class="section-heading"><?php _e('Related','jeg_textdomain'); ?> <strong><?php _e('Posts','jeg_textdomain'); ?></strong></h3>
  38.         </div>
  39.     </div>
  40.         <?php
  41.             $index = 1;
  42.             while ( $the_query->have_posts() ) :
  43.                 $the_query->the_post();
  44.                 if(($index - 1) % 3 === 0) {
  45.                     echo '<div class="row clearfix relatedfix">';
  46.                 }
  47.         ?>
  48.         <div class="col-md-4">
  49.             <article class="post-list">
  50.                 <?php echo apply_filters('jeg_featured_figure_lazy', null, 'half-post-featured'); ?>
  51.                 <header class="content">
  52.                     <h1 class="post-title"><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h1>
  53.                     <div class="post-meta">
  54.                         <span class="post-author"><?php _e('By','jeg_textdomain'); ?>
  55.                             <a href="<?php echo get_author_posts_url(get_the_author_meta('ID')); ?>" rel="author"><?php echo apply_filters('jeg_get_author_name', null); ?></a>
  56.                         </span>
  57.                         <time class="post-date" datetime="<?php echo get_the_time("Y-m-d H:i:s"); ?>">
  58.                             <?php echo human_time_diff( get_the_time('U'), current_time('timestamp') ) . __(' ago', 'jeg_textdomain'); ?>
  59.                         </time>
  60.                     </div>
  61.                 </header>
  62.             </article>
  63.         </div>
  64.         <?php
  65.                 if($index % 3 === 0) echo "</div> <!-- related fix -->";
  66.             $index++;
  67.             endwhile;
  68.             if( ( $index - 1 ) % 3 !== 0 ) echo "</div>";
  69.         ?>
  70. </section>
  71.  
  72. <?php
  73.             endif;
  74.             wp_reset_postdata();
  75.         endif;
  76.     }
  77. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement