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