Advertisement
Guest User

Untitled

a guest
Jul 9th, 2015
226
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.77 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. <?php
  75. /*
  76. the first part of the page (built with the page builder) - empty($paged) or $paged < 2 = first page
  77. ---------------------------------------------------------------------------------------- */
  78. //td_global::$cur_single_template_sidebar_pos = 'no_sidebar';
  79. ?>
  80.  
  81.  
  82. <div class="td-container td-pb-article-list">
  83. <div class="td-pb-row">
  84. <?php
  85. // set the $cur_single_template_sidebar_pos - for gallery and video playlist
  86. td_global::$cur_single_template_sidebar_pos = $loop_sidebar_position;
  87. //the default template
  88. switch ($loop_sidebar_position) {
  89. default: //sidebar right
  90. ?>
  91. <div class="td-pb-span8 td-main-content" role="main">
  92. <div class="td-ss-main-content">
  93. <?php if ((empty($paged) or $paged < 2) and $list_custom_title_show === true) { ?>
  94. <h4 class="block-title"><span><?php echo $td_list_custom_title?></span></h4>
  95. <?php }
  96.  
  97.  
  98. //query_posts(td_data_source::metabox_to_args($td_homepage_loop_filter, $paged));
  99. query_posts(td_data_source::metabox_to_args($td_homepage_loop, $paged));
  100. locate_template('loop.php', true);
  101. echo td_page_generator::get_pagination();
  102. wp_reset_query();
  103. ?>
  104. </div>
  105. </div>
  106. <div class="td-pb-span4 td-main-sidebar" role="complementary">
  107. <div class="td-ss-main-sidebar">
  108. <?php get_sidebar(); ?>
  109. </div>
  110. </div>
  111. <?php
  112. break;
  113.  
  114. case 'sidebar_left':
  115. ?>
  116. <div class="td-pb-span8 td-main-content <?php echo $td_sidebar_position; ?>-content" role="main">
  117. <div class="td-ss-main-content">
  118. <?php if ((empty($paged) or $paged < 2) and $list_custom_title_show === true) { ?>
  119. <h4 class="block-title"><span><?php echo $td_list_custom_title?></span></h4>
  120. <?php }
  121.  
  122. //query_posts(td_data_source::metabox_to_args($td_homepage_loop_filter, $paged));
  123. query_posts(td_data_source::metabox_to_args($td_homepage_loop, $paged));
  124. locate_template('loop.php', true);
  125. echo td_page_generator::get_pagination();
  126. wp_reset_query();
  127. ?>
  128. </div>
  129. </div>
  130. <div class="td-pb-span4 td-main-sidebar" role="complementary">
  131. <div class="td-ss-main-sidebar">
  132. <?php get_sidebar(); ?>
  133. </div>
  134. </div>
  135. <?php
  136. break;
  137.  
  138. case 'no_sidebar':
  139. //td_global::$load_featured_img_from_template = 'art-slide-big';
  140. td_global::$load_featured_img_from_template = 'full';
  141. ?>
  142. <div class="td-pb-span12 td-main-content" role="main">
  143. <div class="td-ss-main-content">
  144. <?php if ((empty($paged) or $paged < 2) and $list_custom_title_show === true) { ?>
  145. <h4 class="block-title"><span><?php echo $td_list_custom_title?></span></h4>
  146. <?php }
  147.  
  148. //query_posts(td_data_source::metabox_to_args($td_homepage_loop_filter, $paged));
  149. query_posts(td_data_source::metabox_to_args($td_homepage_loop, $paged));
  150. locate_template('loop.php', true);
  151. echo td_page_generator::get_pagination();
  152. wp_reset_query();
  153. ?>
  154. </div>
  155. </div>
  156. <?php
  157. break;
  158.  
  159. }
  160. ?>
  161. </div> <!-- /.td-pb-row -->
  162. </div> <!-- /.td-container -->
  163. </div> <!-- /.td-main-content-wrap -->
  164.  
  165. <?php
  166. wp_reset_query();
  167.  
  168. if(!empty($post->post_content)) { //show this only when we have content
  169. if (empty($paged) or $paged < 2) { //show this only on the first page
  170. if (have_posts()) { ?>
  171. <?php while ( have_posts() ) : the_post(); ?>
  172.  
  173. <div class="td-container">
  174. <?php the_content(); ?>
  175. </div>
  176.  
  177. <?php endwhile; ?>
  178. <?php }
  179. }
  180. }
  181.  
  182. get_footer();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement