Advertisement
Uranbold

loop.php

May 26th, 2017
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.73 KB | None | 0 0
  1. <?php
  2. global $coolist_options;
  3.  
  4. $args_featured = array(
  5. 'meta_query' => array(
  6. array(
  7. 'key' => 'themewaves_coolist_options',
  8. 'compare' => 'LIKE',
  9. 'value' => 'featured',
  10. )
  11. )
  12. );
  13. $args_trending = array(
  14. 'meta_query' => array(
  15. array(
  16. 'key' => 'themewaves_coolist_options',
  17. 'compare' => 'LIKE',
  18. 'value' => 'trending',
  19. )
  20. )
  21. );
  22. $args_recent = array();
  23. $args_recent1 = array(
  24. 'meta_query' => array(
  25. 'relation' => 'OR',
  26. array(
  27. 'key' => 'themewaves_coolist_options',
  28. 'compare' => 'NOT EXISTS'
  29. ),
  30. array(
  31. 'key' => 'themewaves_coolist_options',
  32. 'compare' => 'NOT LIKE',
  33. 'value' => 'featured',
  34. )
  35. )
  36. );
  37. $args_recent2 = array(
  38.  
  39. 'meta_query' => array(
  40. 'relation' => 'OR',
  41. array(
  42. 'key' => 'themewaves_coolist_options',
  43. 'compare' => 'NOT EXISTS'
  44. ),
  45. array(
  46. 'relation' => 'AND',
  47. array(
  48. 'key' => 'themewaves_coolist_options',
  49. 'compare' => 'NOT LIKE',
  50. 'value' => 'trending',
  51. ),
  52. array(
  53. 'key' => 'themewaves_coolist_options',
  54. 'compare' => 'NOT LIKE',
  55. 'value' => 'featured',
  56. )
  57. )
  58. )
  59.  
  60. );
  61.  
  62. $args = array();
  63. if(!empty($coolist_options['cat_name']) && $coolist_options['cat_name']!='all_cats'){
  64. $args['category_name'] = $coolist_options['cat_name'];
  65. }
  66.  
  67. $row_class = '';
  68. $blog_rows0 = 1;
  69. if(is_page() && $coolist_options['cat_name'] != 'all_cats'){
  70. if(!empty($coolist_options['row_title']) && !empty($coolist_options['cat_name'])){
  71. $row_title = coolist_option('row_title', esc_html__('Coolist %s', 'coolist'));
  72. $viewall = coolist_option('row_viewall', esc_html__('View all', 'coolist'));
  73. $cat_obj = get_category_by_slug( $coolist_options['cat_name'] );
  74. echo '<div class="row-title"><h3>'.sprintf( esc_html($row_title), ('<span>'.esc_html($cat_obj->cat_name).'</span>') ).'</h3>';
  75. echo '<a href="'.esc_url( get_category_link( $cat_obj->cat_ID ) ).'">'.esc_html($viewall).'</a></div>';
  76. }
  77. } else {
  78. $paged = (get_query_var('paged')) ? intval(get_query_var('paged')) : 1;
  79. $args['paged'] = $paged;
  80. global $page;
  81. if (is_page() && is_front_page() && $page) {
  82. $args['paged'] = $page;
  83. }
  84.  
  85. $row_class = ' blog-infinite';
  86. $title_recent = $title_recent1 = $title_recent2 = coolist_option('whats_new', esc_html__('What\'s New', 'coolist'));
  87. $title_featured = coolist_option('whats_hot', esc_html__('What\'s Hot', 'coolist'));
  88. $title_trending = coolist_option('whats_rising', esc_html__('What\'s Rising', 'coolist'));
  89. $blog_rows0 = coolist_option('posts_per_page', 6);
  90. $coolist_options['pagination'] = coolist_option('blog_pagination', 'infinite');
  91. }
  92.  
  93. $crLt = !empty($coolist_options['blog_layout']) ? $coolist_options['blog_layout'] : 'style_1';
  94. if(!empty($coolist_options['category_layout'])){
  95. $crLt = $coolist_options['category_layout'];
  96. }
  97.  
  98. $rowlayouts = coolist_blog_layout();
  99. $rowlayout = empty($coolist_options['sidebar']) ? $rowlayouts[$crLt]['layout'] : $rowlayouts[$crLt]['layout1'];
  100. $tab_title = '';
  101. $tab_active = ' active';
  102.  
  103. echo '<div class="blog-row '.esc_attr($crLt.$row_class).'">';
  104. if(isset($rowlayout[0])){
  105. $i = 0;
  106. foreach ($rowlayout as $pposts){
  107. if(!empty($coolist_options['post__not_in'])){
  108. $args['post__not_in'] = $coolist_options['post__not_in'];
  109. }
  110. $blog_rows = $blog_rows0;
  111. if(is_array($pposts['position'])){
  112. $position = $pposts['position'][0];
  113. if($position != 'list') {
  114. $blog_rows = $blog_rows * count($pposts['position']);
  115. }
  116. $pposts['position'] = $position;
  117.  
  118. }
  119.  
  120. switch ($pposts['position']) {
  121. case 'list':
  122. $args['posts_per_page'] = ($blog_rows * 3);
  123. if(!empty($coolist_options['category_list']) && $coolist_options['category_list'] == 'style_2'){
  124. $args['posts_per_page'] = ($blog_rows * 4);
  125. $pposts['position'] = 'list2';
  126. }
  127. break;
  128. default:
  129. $args['posts_per_page'] = $blog_rows;
  130. break;
  131. }
  132. $meta_query = 'args_'.$pposts['query'];
  133.  
  134. if(empty($row_title) && isset($title_recent)){
  135. $title = 'title_'.$pposts['query'];
  136. $tab_title .= '<h5 class="tab-title'.esc_attr($tab_active).'" data-href="blog-column-'.esc_attr($i).'">'.esc_html($$title).'</h5>';
  137. }
  138. if($pposts['position'] == 'large' && !empty($coolist_options['category_large']) && $coolist_options['category_large'] == 'style_2'){
  139. $pposts['position'] = 'large2';
  140. } elseif($pposts['position'] == 'grid' && !empty($coolist_options['category_grid']) && $coolist_options['category_grid'] == 'style_2'){
  141. $pposts['position'] = 'grid2';
  142. }
  143.  
  144. $newargs = array_merge($args, $$meta_query);
  145.  
  146. query_posts( $newargs );
  147.  
  148. if(have_posts()){
  149. echo '<div class="blog-column'.esc_attr($tab_active).'" data-id="blog-column-'.esc_attr($i).'">';
  150. if(!empty($$title)){
  151. echo '<h5 class="column-title">'.esc_html($$title).'</h5>';
  152. }
  153. echo '<div class="column-posts">';
  154.  
  155. while ( have_posts() ) { the_post();
  156. get_template_part('content', $pposts['position']);
  157. }
  158.  
  159. if(!empty($coolist_options['pagination'])){
  160. coolist_pagination();
  161. }
  162. echo '</div>';
  163. echo '</div>';
  164. }
  165.  
  166. wp_reset_query();
  167. $i++;
  168. $tab_active = '';
  169. }
  170. if($tab_title){
  171. echo '<div class="tw-blog-tab">'.($tab_title).'</div>';
  172. }
  173. }
  174.  
  175. echo '</div>';
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement