Guest User

Untitled

a guest
Aug 19th, 2016
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.26 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. //read the metadata for the post
  32. $td_homepage_loop = get_post_meta($post->ID, 'td_homepage_loop', true);
  33.  
  34.  
  35. if (!empty($td_homepage_loop['td_layout'])) {
  36. $loop_module_id = $td_homepage_loop['td_layout'];
  37. }
  38.  
  39. if (!empty($td_homepage_loop['td_sidebar_position'])) {
  40. $loop_sidebar_position = $td_homepage_loop['td_sidebar_position'];
  41. }
  42.  
  43. if (!empty($td_homepage_loop['td_sidebar'])) {
  44. td_global::$load_sidebar_from_template = $td_homepage_loop['td_sidebar'];
  45. }
  46.  
  47. if (!empty($td_homepage_loop['list_custom_title'])) {
  48. $td_list_custom_title = $td_homepage_loop['list_custom_title'];
  49. } else {
  50. $td_list_custom_title =__td('LATEST ARTICLES');
  51. }
  52.  
  53.  
  54. if (!empty($td_homepage_loop['list_custom_title_show'])) {
  55. $list_custom_title_show = false;
  56. }
  57. }
  58.  
  59.  
  60. // the first part of the page (built with the page builder) - empty($paged) or $paged < 2 = first page
  61. //---------------------------------------------------------------------------------------- */
  62.  
  63. ?>
  64.  
  65.  
  66. <div class="td-container td-pb-article-list">
  67. <div class="td-container-border">
  68. <div class="td-pb-row">
  69. <?php
  70.  
  71. //the default template
  72. switch ($loop_sidebar_position) {
  73. default: //sidebar right
  74. ?>
  75. <div class="td-pb-span8 td-main-content" role="main">
  76. <div class="td-ss-main-content">
  77. <?php if ((empty($paged) or $paged < 2) and $list_custom_title_show === true) { ?>
  78. <h4 class="block-title"><span><?php echo $td_list_custom_title?></span></h4>
  79. <?php }
  80.  
  81.  
  82. query_posts(td_data_source::metabox_to_args($td_homepage_loop, $paged));
  83. locate_template('loop.php', true);
  84. td_page_generator::get_pagination();
  85. wp_reset_query();
  86. ?>
  87. </div>
  88. </div>
  89. <div class="td-pb-span4 td-main-sidebar" role="complementary">
  90. <div class="td-ss-main-sidebar">
  91. <?php get_sidebar(); ?>
  92. </div>
  93. </div>
  94. <?php
  95. break;
  96.  
  97. case 'sidebar_left':
  98. ?>
  99. <div class="td-pb-span8 td-main-content td-sidebar-left-content" role="main">
  100. <div class="td-ss-main-content">
  101. <?php if ((empty($paged) or $paged < 2) and $list_custom_title_show === true) { ?>
  102. <h4 class="block-title"><span><?php echo $td_list_custom_title?></span></h4>
  103. <?php }
  104. query_posts(td_data_source::metabox_to_args($td_homepage_loop, $paged));
  105. locate_template('loop.php', true);
  106. td_page_generator::get_pagination();
  107. wp_reset_query();
  108. ?>
  109. </div>
  110. </div>
  111. <div class="td-pb-span4 td-main-sidebar" role="complementary">
  112. <div class="td-ss-main-sidebar">
  113. <?php get_sidebar(); ?>
  114. </div>
  115. </div>
  116. <?php
  117. break;
  118.  
  119. case 'no_sidebar':
  120. td_global::$load_featured_img_from_template = 'full';
  121. ?>
  122. <div class="td-pb-span12 td-main-content" role="main">
  123. <div class="td-ss-main-content">
  124. <?php if ((empty($paged) or $paged < 2) and $list_custom_title_show === true) { ?>
  125. <h4 class="block-title"><span><?php echo $td_list_custom_title?></span></h4>
  126. <?php }
  127. query_posts(td_data_source::metabox_to_args($td_homepage_loop, $paged));
  128. locate_template('loop.php', true);
  129. td_page_generator::get_pagination();
  130. wp_reset_query();
  131. ?>
  132. </div>
  133. </div>
  134. <?php
  135. break;
  136.  
  137. }
  138. ?>
  139. </div> <!-- /.td-pb-row -->
  140. </div>
  141. </div> <!-- /.td-container -->
  142.  
  143. <?php
  144.  
  145. if(!empty($post->post_content)) { //show this only when we have content
  146. if (empty($paged) or $paged < 2) { //show this only on the first page
  147. if (have_posts()) { ?>
  148. <?php while ( have_posts() ) : the_post(); ?>
  149.  
  150. <div class="td-container">
  151. <div class="td-container-border">
  152. <?php
  153. the_content();
  154.  
  155. ?>
  156. </div>
  157. </div>
  158.  
  159. <?php endwhile; ?>
  160. <?php }
  161. }
  162. }
  163.  
  164. get_footer();
Advertisement
Add Comment
Please, Sign In to add comment