Guest User

Untitled

a guest
Aug 3rd, 2016
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.81 KB | None | 0 0
  1. <?php
  2. /* Template Name: Pagebuilder + latest articles + pagination */
  3.  
  4. get_header();
  5.  
  6. td_global::$current_template = 'page-homepage-loop';
  7.  
  8. global $paged, $loop_module_id, $loop_sidebar_position, $post, $more; //$more is a hack to fix the read more loop
  9. $td_page = (get_query_var('page')) ? get_query_var('page') : 1; //rewrite the global var
  10. $td_paged = (get_query_var('paged')) ? get_query_var('paged') : 1; //rewrite the global var
  11.  
  12.  
  13. //paged works on single pages, page - works on homepage
  14. if ($td_paged > $td_page) {
  15. $paged = $td_paged;
  16. } else {
  17. $paged = $td_page;
  18. }
  19.  
  20.  
  21. $list_custom_title_show = true; //show the article list title by default
  22.  
  23.  
  24.  
  25.  
  26. /*
  27. read the settings for the loop
  28. ---------------------------------------------------------------------------------------- */
  29. if (!empty($post->ID)) {
  30. td_global::load_single_post($post);
  31.  
  32. //read the metadata for the post
  33. //
  34. // the $td_homepage_loop is used instead
  35. //$td_homepage_loop_filter = get_post_meta($post->ID, 'td_homepage_loop_filter', true); //it's send to td_data_source
  36. $td_homepage_loop = get_post_meta($post->ID, 'td_homepage_loop', true);
  37.  
  38.  
  39. if (!empty($td_homepage_loop['td_layout'])) {
  40. $loop_module_id = $td_homepage_loop['td_layout'];
  41. }
  42.  
  43. if (!empty($td_homepage_loop['td_sidebar_position'])) {
  44. $loop_sidebar_position = $td_homepage_loop['td_sidebar_position'];
  45. }
  46.  
  47. // sidebar position used to align the breadcrumb on sidebar left + sidebar first on mobile issue
  48. $td_sidebar_position = '';
  49. if($loop_sidebar_position == 'sidebar_left') {
  50. $td_sidebar_position = 'td-sidebar-left';
  51. }
  52.  
  53. if (!empty($td_homepage_loop['td_sidebar'])) {
  54. td_global::$load_sidebar_from_template = $td_homepage_loop['td_sidebar'];
  55. }
  56.  
  57. if (!empty($td_homepage_loop['list_custom_title'])) {
  58. $td_list_custom_title = $td_homepage_loop['list_custom_title'];
  59. } else {
  60. $td_list_custom_title =__td('LATEST ARTICLES', TD_THEME_NAME);
  61. }
  62.  
  63.  
  64. if (!empty($td_homepage_loop['list_custom_title_show'])) {
  65. $list_custom_title_show = false;
  66. }
  67.  
  68.  
  69. }
  70. ?>
  71.  
  72. <div class="td-main-content-wrap td-main-page-wrap">
  73.  
  74.  
  75.  
  76.  
  77. <div class="td-container td-pb-article-list">
  78. <div class="td-pb-row">
  79. <?php
  80. // set the $cur_single_template_sidebar_pos - for gallery and video playlist
  81. td_global::$cur_single_template_sidebar_pos = $loop_sidebar_position;
  82. //the default template
  83. switch ($loop_sidebar_position) {
  84. default: //sidebar right
  85. ?>
  86. <div class="td-pb-span8 td-main-content" role="main">
  87. <div class="td-ss-main-content">
  88. <?php if ((empty($paged) or $paged < 2) and $list_custom_title_show === true) { ?>
  89. <h4 class="block-title"><span><?php echo $td_list_custom_title?></span></h4>
  90. <?php }
  91.  
  92.  
  93. //query_posts(td_data_source::metabox_to_args($td_homepage_loop_filter, $paged));
  94. query_posts(td_data_source::metabox_to_args($td_homepage_loop, $paged));
  95. locate_template('loop.php', true);
  96. td_page_generator::get_pagination();
  97. wp_reset_query();
  98. ?>
  99. </div>
  100. </div>
  101. <div class="td-pb-span4 td-main-sidebar" role="complementary">
  102. <div class="td-ss-main-sidebar">
  103. <?php get_sidebar(); ?>
  104. </div>
  105. </div>
  106. <?php
  107. break;
  108.  
  109. case 'sidebar_left':
  110. ?>
  111. <div class="td-pb-span8 td-main-content <?php echo $td_sidebar_position; ?>-content" role="main">
  112. <div class="td-ss-main-content">
  113. <?php if ((empty($paged) or $paged < 2) and $list_custom_title_show === true) { ?>
  114. <h4 class="block-title"><span><?php echo $td_list_custom_title?></span></h4>
  115. <?php }
  116.  
  117. //query_posts(td_data_source::metabox_to_args($td_homepage_loop_filter, $paged));
  118. query_posts(td_data_source::metabox_to_args($td_homepage_loop, $paged));
  119. locate_template('loop.php', true);
  120. td_page_generator::get_pagination();
  121. wp_reset_query();
  122. ?>
  123. </div>
  124. </div>
  125. <div class="td-pb-span4 td-main-sidebar" role="complementary">
  126. <div class="td-ss-main-sidebar">
  127. <?php get_sidebar(); ?>
  128. </div>
  129. </div>
  130. <?php
  131. break;
  132.  
  133. case 'no_sidebar':
  134. //td_global::$load_featured_img_from_template = 'art-slide-big';
  135. td_global::$load_featured_img_from_template = 'full';
  136. ?>
  137. <div class="td-pb-span12 td-main-content" role="main">
  138. <div class="td-ss-main-content">
  139. <?php if ((empty($paged) or $paged < 2) and $list_custom_title_show === true) { ?>
  140. <h4 class="block-title"><span><?php echo $td_list_custom_title?></span></h4>
  141. <?php }
  142.  
  143. //query_posts(td_data_source::metabox_to_args($td_homepage_loop_filter, $paged));
  144. query_posts(td_data_source::metabox_to_args($td_homepage_loop, $paged));
  145. locate_template('loop.php', true);
  146. td_page_generator::get_pagination();
  147. wp_reset_query();
  148. ?>
  149. </div>
  150. </div>
  151. <?php
  152. break;
  153.  
  154. }
  155. ?>
  156. </div> <!-- /.td-pb-row -->
  157. </div> <!-- /.td-container -->
  158.  
  159. <?php
  160. /*
  161. the first part of the page (built with the page builder) - empty($paged) or $paged < 2 = first page
  162. ---------------------------------------------------------------------------------------- */
  163. //td_global::$cur_single_template_sidebar_pos = 'no_sidebar';
  164. if(!empty($post->post_content)) { //show this only when we have content
  165. if (empty($paged) or $paged < 2) { //show this only on the first page
  166. if (have_posts()) { ?>
  167. <?php while ( have_posts() ) : the_post(); ?>
  168.  
  169. <div class="td-container">
  170. <?php the_content(); ?>
  171. </div>
  172.  
  173. <?php endwhile; ?>
  174. <?php }
  175. }
  176. }
  177.  
  178. ?>
  179. </div> <!-- /.td-main-content-wrap -->
  180.  
  181. <?php
  182.  
  183. get_footer();
Advertisement
Add Comment
Please, Sign In to add comment