Advertisement
Guest User

Untitled

a guest
Oct 20th, 2015
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.66 KB | None | 0 0
  1. <?php
  2. /*
  3. Template name: Homepage version 3
  4. */
  5. the_post();
  6. $nrposts = get_post_meta($post->ID, '_home3_nrposts', true);
  7. if($nrposts == 0) {
  8. $nrposts = 6;
  9. }
  10. $categories = get_post_meta($post->ID, '_home3_categories', true);
  11. $categories_normal = get_post_meta($post->ID, '_home3_categories_normal', true);
  12. get_header();
  13. global $teo_data;
  14.  
  15. $variation = 0;
  16. if(isset($teo_data['header-type']) && $teo_data['header-type'] != '') {
  17. $variation = (int)$teo_data['header-type'];
  18. }
  19. if($variation == 0 || $variation == '') {
  20. $variation = 1;
  21. }
  22. ?>
  23.  
  24. <main role="main" id="post-container">
  25. <?php get_header('variation' . $variation);?>
  26. <section class="normal-slider-wrap">
  27. <div class="container">
  28. <div class="row">
  29. <div class="col-sm-12">
  30. <section class="slider-controls">
  31. <button type="button" class="next"><i class="icon-angle-right"></i></button>
  32. <div class="counter">
  33. <span class="current-slide">1</span>
  34. <span class="separator">/</span>
  35. <span class="count-slides">3</span>
  36. </div>
  37. <button type="button" class="prev"><i class="icon-angle-left"></i></button>
  38. </section>
  39. <div class="normal-slider">
  40. <?php
  41. $args = array();
  42. $args['post_type'] = 'post';
  43. $args['posts_per_page'] = $nrposts;
  44. if(is_array($categories) ) {
  45. $args['category__in'] = $categories;
  46. }
  47. $query = new WP_Query($args);
  48. $i = 1;
  49. while($query->have_posts() ) : $query->the_post(); global $post;
  50. $thumb = wp_get_attachment_url( get_post_thumbnail_id($post->ID) );
  51. $resized = teo_resize($thumb, 1140, 700);
  52. $bginline = '';
  53. if($resized != '') {
  54. $bginline = ' style="background-image: url(\'' . $resized . '\')"';
  55. }
  56. $likes = (int)get_post_meta($post->ID, '_teo_nr_likes', true);
  57. $ip = $_SERVER['REMOTE_ADDR'];
  58. $postIPs = get_post_meta($post->ID, '_teo_post_likes', true);
  59. $liked = 0;
  60. if($postIPs) {
  61. $postIPs = unserialize($postIPs);
  62.  
  63. if(is_array($postIPs) && in_array($ip, $postIPs) ) {
  64. $liked = 1;
  65. }
  66. }
  67. ?>
  68. <article class="slide <?php if($i==1) echo 'visible';?>" <?php echo $bginline;?>>
  69. <div class="overlay"></div>
  70. <div class="inner">
  71. <div class="inner-overlay">
  72. <h2><a href="<?php the_permalink();?>"><?php the_title();?></a></h2>
  73. <div class="details">
  74. <?php echo __('by', 'arwyn') . ' '; the_author_posts_link();?> <span>/</span>
  75. <a href="<?php the_permalink();?>"><?php the_time( get_option( 'date_format' ) ); ?></a> <span>/</span>
  76. <?php the_category(', '); ?>
  77. </div>
  78. <div class="separator"></div>
  79. <p><?php echo wp_trim_words(get_the_content(), 55, '...');?></p>
  80. <div class="separator"></div>
  81. <div class="icons">
  82. <a href="<?php echo comments_link();?>"><i class="icon-comment"></i> <span><?php comments_number('0', '1', '%'); ?></span></a>
  83.  
  84. <a href="#" data-id="<?php echo $post->ID;?>" class="text icn-like <?php if($liked == 1) echo 'liked';?>">
  85. <i class="icon-heart"></i>
  86. <span><?php echo $likes;?></span>
  87. </a>
  88. </div>
  89. </div>
  90. </div>
  91. </article>
  92. <?php $i++; endwhile; wp_reset_postdata(); ?>
  93. </div>
  94. </div>
  95. </div>
  96. </div>
  97. </section>
  98.  
  99. <section class="homepage-articles">
  100. <div class="container">
  101. <div class="row">
  102. <div class="col-sm-12">
  103. <?php
  104. echo '<span class="post_id" data-id="' . $post->ID . '" style="display: none"></span>';
  105. $args = array();
  106. $args['post_type'] = 'post';
  107. if(is_array($categories_normal) ) {
  108. $args['category__in'] = $categories_normal;
  109. }
  110. query_posts($args);
  111. while(have_posts() ) : the_post(); global $post;
  112. $thumb = wp_get_attachment_url( get_post_thumbnail_id($post->ID) );
  113. $resized = teo_resize($thumb, 650, 310);
  114. $bginline = '';
  115. if($resized != '') {
  116. $bginline = ' style="background-image: url(\'' . $resized . '\')"';
  117. }
  118. ?>
  119. <article class="slide" <?php echo $bginline;?>>
  120. <div class="overlay"></div>
  121. <div class="inner">
  122. <div class="inner-overlay">
  123. <h2><a href="<?php the_permalink();?>"><?php the_title();?></a></h2>
  124. <div class="separator"></div>
  125. <div class="details">
  126. <?php echo __('by', 'arwyn') . ' '; the_author_posts_link();?> <span>/</span>
  127. <a href="<?php the_permalink();?>"><?php the_time( get_option( 'date_format' ) ); ?></a> <span>/</span>
  128. <?php the_category(', '); ?>
  129. </div>
  130. </div>
  131. </div>
  132. </article>
  133. <?php endwhile; wp_reset_query(); ?>
  134. </div>
  135. </div>
  136. </div>
  137. </section>
  138.  
  139. </main>
  140.  
  141. <script id="article-template" type="text/x-handlebars-template">
  142. <article class="slide" style="background-image: url({{image}})">
  143. <div class="overlay"></div>
  144. <div class="inner">
  145. <div class="inner-overlay">
  146. <h2><a href="{{link}}">{{title}}</a></h2>
  147. <div class="separator"></div>
  148. <div class="details">
  149. <a href="{{authorLink}}">by {{author}}</a> <span>/</span>
  150. <a href="{{dateLink}}">{{date}}</a> <span>/</span>
  151. <a href="{{categoryLink}}">{{{category}}}</a>
  152. </div>
  153. </div>
  154. </div>
  155. </article>
  156. </script>
  157.  
  158. <?php get_footer();?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement