Advertisement
darrenbachan

Untitled

Jun 20th, 2016
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.49 KB | None | 0 0
  1. <?php
  2.     if ( is_single()) {
  3.         $categories = get_the_category();
  4.         if ($categories) {
  5.             $category = $categories[0]; //foreach ($categories as $category)
  6.             $cat = $category->cat_ID;
  7.         }
  8.         $args=array(
  9.             'cat' => $cat,
  10.             'order' => 'DESC',
  11.             'post__not_in' => array($post->ID),
  12.             'posts_per_page'=>2,
  13.             'caller_get_posts'=>1
  14.         );
  15.     } else if(is_front_page()) {    
  16.         $args = array(
  17.             'order' => 'DESC',
  18.             'orderby' => 'date',
  19.             'posts_per_page'=>3,
  20.             'post_type' => 'post',
  21.             'caller_get_posts'=>1
  22.         );
  23.     }
  24.  
  25.     $my_query = null;
  26.     $my_query = new WP_Query($args);
  27.     if( $my_query->have_posts() ) {
  28.         while ($my_query->have_posts()) : $my_query->the_post(); ?>
  29.         <div class="col-xs-12 <?php if(is_front_page()) { echo 'col-sm-4 col-md-4'; } else { echo 'col-sm-6 col-md-6'; } ?>">
  30.             <div class="recent-blog-post-item">
  31.                 <?php if(has_post_thumbnail()) : ?>
  32.                 <div class="blog-post-featured-img">
  33.                     <a href="<?php the_permalink(); ?>
  34.                         ">
  35.                         <div class="featured-banner" style="background: url(<?php the_post_thumbnail_url( 'full' ); ?> ) no-repeat center center; background-size: cover;">
  36.                         </div>
  37.                     </a>
  38.                 </div>
  39.                 <?php endif; ?>
  40.  
  41.                 <div class="blog-post-content recent-meta-text">
  42.                     <div class="recent-meta-title">
  43.                         <a href="<? the_permalink()?>
  44.                             " rel="bookmark" title="
  45.                             <?php the_title(); ?>
  46.                             ">
  47.                             <h4>
  48.                                 <?php the_title(); ?></h4>
  49.                         </a>
  50.                     </div>
  51.  
  52.                     <div class="blog-post-meta">
  53.                         <div class="meta-text">
  54.                             <div class="meta-author">
  55.                                 <a href="<?php echo get_author_posts_url(get_the_author_meta('ID')); ?>"><?php the_author(); ?></a>
  56.                             </div>
  57.  
  58.                             <time class="meta-time" datetime="<?php echo date(DATE_W3C); ?>">
  59.                                 <i class="fa fa-clock-o"></i> <?php the_time('F jS, Y'); ?>
  60.                             </time>
  61.                         </div>
  62.                     </div><!-- end blog post meta -->
  63.  
  64.                     <div class="recent-meta-excerpt">
  65.                         <div class="excerpt-fix">
  66.                             <?php echo excerpt(25);?>
  67.                         </div>
  68.  
  69.                         <a class="read-more" href="<?php the_permalink(); ?>
  70.                             ">Read More <i class="fa fa-long-arrow-right"></i>
  71.                         </a>
  72.                     </div>
  73.                 </div>
  74.                 <!-- end recent meta text -->
  75.             </div>
  76.             <!-- end recent blog post item -->
  77.         </div>
  78.     <?php endwhile; wp_reset_query();
  79.     } else { ?>
  80.         <div class="col-md-12">
  81.             <?php _e('Sorry! There are no related articles based on this category.', 'roster-list'); ?>
  82.         </div>
  83.     <?php
  84.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement