Advertisement
trongvodang

Untitled

Jul 18th, 2016
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 10.84 KB | None | 0 0
  1. <?php
  2. /**
  3. * The main template file.
  4. *
  5. * Used to display the homepage when home.php doesn't exist.
  6. */
  7. ?>
  8. <?php
  9. // Get options
  10. $mts_options = get_option(MTS_THEME_NAME);
  11.  
  12. // Featured Section 1 settings ( slider is here) --------------------------------
  13. $slider_enabled = ( $mts_options['mts_featured_slider'] === '1' ) ? true : false;
  14.  
  15. if ( empty($mts_options['mts_featured_slider_cat']) || !is_array($mts_options['mts_featured_slider_cat']) ) {
  16. $mts_options['mts_featured_slider_cat'] = array('0');
  17. }
  18. $slider_cat = implode(",", $mts_options['mts_featured_slider_cat']);
  19.  
  20. // Featured Section settings --------------------------------------------------
  21. $f2_title = $mts_options['mts_featured_section_2_title'];
  22. if ( empty($mts_options['mts_featured_section_2_cat']) || !is_array($mts_options['mts_featured_section_2_cat']) ) {
  23. $mts_options['mts_featured_section_2_cat'] = array('0');
  24. }
  25. $f2_cat= implode(",", $mts_options['mts_featured_section_2_cat']);
  26. // Featured Section 3 settings --------------------------------------------------
  27. get_header(); ?>
  28. <div id="page">
  29. <div class="article">
  30. <?php if ( $slider_enabled && is_home() && !is_paged() ) { ?>
  31. <section id="featured-section-1" class="featured-section featured-section-1-1 clearfix">
  32. <div class="slider-container">
  33. <div class="primary-slider-container clearfix loading">
  34. <div id="slider" class="primary-slider">
  35. <?php
  36. $slider_full = 'best-featuredfull';
  37. if ( empty( $mts_options['mts_custom_slider'] ) ) {
  38. $my_query = new WP_Query('cat='.$slider_cat.'&posts_per_page='.$mts_options['mts_featured_slider_num']);
  39. while ( $my_query->have_posts() ) : $my_query->the_post();
  40. ?>
  41. <div>
  42. <a href="<?php the_permalink(); ?>">
  43. <?php the_post_thumbnail($slider_full,array('title' => '')); ?>
  44. <div class="slider-caption">
  45. <?php if(isset($mts_options['mts_home_headline_meta_info']['enabled']) && $mts_options['mts_home_headline_meta_info']['enabled']){ ?>
  46. <div class="sliderdate">
  47. <?php if(isset($mts_options['mts_home_headline_meta_info']['enabled']['date']) == '1') { ?>
  48. <span class="thetime updated"><?php the_time( get_option( 'date_format' ) ); ?></span>
  49. <?php } ?>
  50. </div>
  51. <?php } ?>
  52. <h2 class="slide-title"><?php the_title(); ?></h2>
  53. </div>
  54. <div class="post-day"><?php if (function_exists('wp_review_show_total')) wp_review_show_total(true, 'review-total-only'); ?></div>
  55. </a>
  56. </div>
  57. <?php endwhile; wp_reset_postdata();
  58. } else { ?>
  59. <?php foreach( $mts_options['mts_custom_slider'] as $slide ) : ?>
  60. <div>
  61. <a href="<?php echo esc_url( $slide['mts_custom_slider_link'] ); ?>">
  62. <?php echo wp_get_attachment_image( $slide['mts_custom_slider_image'], $slider_full, false, array('title' => '') ); ?>
  63. <div class="slider-caption">
  64. <div class="sliderdate"><?php echo esc_html( $slide['mts_custom_slider_title'] ); ?></div>
  65. <h2 class="slide-title"><?php echo esc_html( $slide['mts_custom_slider_text'] ); ?></h2>
  66. </div>
  67. </a>
  68. </div>
  69. <?php endforeach; ?>
  70. <?php } ?>
  71. </div>
  72. </div>
  73. </div><!-- slider-container -->
  74. </section>
  75. <?php } ?>
  76. <?php if( $mts_options['mts_featured_section_2'] === '1' && is_home() && !is_paged() ) {// featured section 2 ?>
  77. <section id="featured-section-3" class="featured-section clearfix">
  78. <?php if (!empty($f2_title)) { ?><h4 class="featured-section-title"><?php echo $f2_title;?></h4><?php } ?>
  79. <?php
  80. $f2_query = new WP_Query('cat='.$f2_cat.'&posts_per_page=4');
  81.  
  82. $f2_count = 1; if ($f2_query->have_posts()) : while ($f2_query->have_posts()) : $f2_query->the_post();
  83.  
  84. $f2_loop_params = best_mixed_layout_params( 1, 2, $f2_count );// see functions.php
  85.  
  86. $f2_clear_class = $f2_loop_params['clear_class'];
  87. $f2_type_class = $f2_loop_params['box_class'];
  88. $f2_loop_thumb = $f2_loop_params['thumb'];
  89. $f2_show_excerpt = $f2_loop_params['show_excerpt'];
  90. $f2_show_author = $f2_loop_params['show_author'];
  91. $begin_f2_extra_wrappers = $f2_loop_params['open_wrappers'];
  92. $end_f2_extra_wrappers = $f2_loop_params['close_wrappers'];
  93. ?>
  94. <article class="post-box latestPost mixed <?php echo $f2_type_class;?> <?php echo $f2_clear_class;?>">
  95. <?php echo $begin_f2_extra_wrappers; ?>
  96. <div class="post-img">
  97. <a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>" rel="nofollow">
  98. <?php the_post_thumbnail($f2_loop_thumb,array('title' => '')); ?>
  99. </a>
  100. </div>
  101. <div class="post-data">
  102. <div class="post-data-container">
  103. <header>
  104. <h2 class="title post-title"><a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><?php the_title(); ?></a></h2>
  105. <?php mts_the_postinfo(); ?>
  106. </header>
  107. <?php if ($f2_show_excerpt) : ?>
  108. <div class="post-excerpt">
  109. <?php echo mts_excerpt(14); ?>
  110. </div>
  111. <?php endif; ?>
  112. </div>
  113. </div>
  114. <?php echo $end_f2_extra_wrappers; ?>
  115. </article><!--.post-box-->
  116. <?php $f2_count++; endwhile;
  117. endif; wp_reset_postdata();
  118. ?>
  119. </section><!--#featured-section-3-->
  120. <?php } ?>
  121. <div id="content_box">
  122. <?php $latest_posts_used = false;
  123. if ( !empty( $mts_options['mts_featured_categories'] ) ) {
  124. foreach ( $mts_options['mts_featured_categories'] as $section ) {
  125. $category_id = $section['mts_featured_category'];
  126. $featured_category_layout = $section['mts_featured_category_layout'];
  127. $posts_num = $section['mts_featured_category_postsnum'];
  128. if ( $category_id === 'latest' && ! $latest_posts_used ) {
  129. $latest_posts_used = true;
  130. $fc_section_class = ( in_array( $featured_category_layout, array( 'vertical', 'mixed' ) ) ) ? '' : ' '.$featured_category_layout;
  131. ?>
  132. <section id="latest-posts" class="clearfix<?php echo $fc_section_class ?><?php //echo $fc_section_no_gap ?>">
  133. <h4 class="featured-section-title"><?php _e( "Latest Articles", "best" ); ?></h4>
  134. <?php $j = 1; if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
  135. <?php best_the_homepage_article( $featured_category_layout, $j, true );?>
  136. <?php $j++; endwhile; endif; ?>
  137. <!--Start Pagination-->
  138. <?php if (isset($mts_options['mts_pagenavigation_type']) && $mts_options['mts_pagenavigation_type'] == '1' ) { ?>
  139. <?php $additional_loop = 0; mts_pagination($additional_loop['max_num_pages']); ?>
  140. <?php } else { ?>
  141. <div class="pagination pagination-previous-next">
  142. <ul>
  143. <li class="nav-previous"><?php next_posts_link( '<i class="fa fa-chevron-left"></i> '. __( 'Previous', 'best' ) ); ?></li>
  144. <li class="nav-next"><?php previous_posts_link( __( 'Next', 'best' ).' <i class="fa fa-chevron-right"></i>' ); ?></li>
  145. </ul>
  146. </div>
  147. <?php } ?>
  148. <!--End Pagination-->
  149. </section><!--#latest-posts-->
  150. <?php } elseif ( $category_id !== 'latest' && !is_paged() ) {
  151.  
  152. $fc_section_class = ( in_array( $featured_category_layout, array( 'vertical', 'mixed' ) ) ) ? '' : ' '.$featured_category_layout;
  153.  
  154. ?>
  155. <section class="featured-section clearfix<?php echo $fc_section_class ?>">
  156. <h4 class="featured-section-title"><a href="<?php echo esc_url( get_category_link($category_id) ); ?>" title="<?php echo esc_attr( get_cat_name($category_id) ); ?>"><?php echo get_cat_name($category_id); ?></a></h4>
  157. <?php $cat_query = new WP_Query('cat='.$category_id.'&posts_per_page='.$posts_num); ?>
  158. <?php $j = 1; if ($cat_query->have_posts()) : while ($cat_query->have_posts()) : $cat_query->the_post(); ?>
  159. <?php best_the_homepage_article( $featured_category_layout, $j );?>
  160. <?php $j++; endwhile; endif; wp_reset_postdata();?>
  161. </section>
  162. <?php } ?>
  163. <?php } ?>
  164. <?php } ?>
  165. </div>
  166. </div>
  167. <?php get_sidebar(); ?>
  168. <?php get_footer(); ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement