bdbrown

homepage.php

Jan 8th, 2016
161
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.82 KB | None | 0 0
  1. <?php
  2. /*
  3. Template Name: Homepage
  4. */
  5. ?>
  6.  
  7. <?php get_header(); ?>
  8.  
  9. <section class="content">
  10.  
  11.     <?php get_template_part('inc/page-title'); ?>
  12.    
  13.     <div class="pad group">
  14.        
  15.         <?php get_template_part('inc/featured'); ?>
  16.        
  17.         <?php
  18.             // remove default pre_get_posts action
  19.             remove_action( 'pre_get_posts', 'alx_pre_get_posts' );
  20.  
  21.             // set posts per page variable
  22.             $nbr_posts = 6;
  23.        
  24.             // get featured image post ids and set query arguments
  25.             if ( ot_get_option('featured-posts-count') != '0' ) :
  26.                 // Get featured post ids
  27.                 $featured_post_ids = alx_get_featured_post_ids();
  28.                 // Exclude posts
  29.                 if ( $featured_post_ids && !ot_get_option('featured-posts-include') ) :
  30.                     $args = array( 'post__not_in' => $featured_post_ids, 'posts_per_page' => $nbr_posts );
  31.                 else:
  32.                     $args = array( 'posts_per_page' => $nbr_posts );
  33.                 endif;
  34.             endif;
  35.  
  36.             // run query for home page
  37.             $homepage_posts = new WP_Query( $args );
  38.            
  39.             // reinstate default pre_get_posts action
  40.             add_action( 'pre_get_posts', 'alx_pre_get_posts' );
  41.         ?>
  42.  
  43.         <?php if ( $homepage_posts->have_posts() ) : ?>
  44.        
  45.             <?php if ( ot_get_option('blog-standard') == 'on' ): ?>
  46.                 <?php while ( $homepage_posts->have_posts() ): $homepage_posts->the_post(); ?>
  47.                     <?php get_template_part('content-standard'); ?>
  48.                 <?php endwhile; ?>
  49.             <?php else: ?>
  50.             <div class="post-list group">
  51.                 <?php $i = 1; echo '<div class="post-row">'; while ( $homepage_posts->have_posts() ): $homepage_posts->the_post(); ?>
  52.                     <?php get_template_part('content'); ?>
  53.                 <?php if($i % 2 == 0) { echo '</div><div class="post-row">'; } $i++; endwhile; echo '</div>'; ?>
  54.             </div><!--/.post-list-->
  55.             <?php endif; ?>
  56.            
  57.         <?php endif; ?>
  58.        
  59.     </div><!--/.pad-->
  60.    
  61. </section><!--/.content-->
  62.  
  63. <?php get_sidebar(); ?>
  64.  
  65. <?php get_footer(); ?>
Advertisement
Add Comment
Please, Sign In to add comment