This repository has been archived by the owner on Jan 28, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5
/
single-masonry.php
167 lines (147 loc) · 4.49 KB
/
single-masonry.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
<div id="post-masonry" class="container-fluid">
<div class="row">
<?php
$pnum = isset($_GET['pnum']) ? intval($_GET['pnum']) : 1;
$tags_related = get_the_tags();
if (!empty($tags_related)) {
$tag_in = array();
foreach ($tags_related as $tag_related) {
array_push($tag_in, $tag_related->term_id);
}
$args = array(
'tag__in' => $tag_in,
'post__not_in' => array(get_the_ID()),
'meta_query' => array(
'relation' => 'OR',
array(
'key' => '_Original Post ID',
'compare' => 'NOT EXISTS'
),
array(
'key' => '_Original Post ID',
'value' => 'deleted'
)
),
'paged' => $pnum
);
query_posts($args);
$maxpage = $wp_query->max_num_pages;
//if no posts with same tags, find posts with same category (MACSE)
if ($wp_query->post_count == 0) {
$category_in = array();
foreach (get_the_category() as $category) {
array_push($category_in, $category->cat_ID);
}
$args = array(
'category__in' => $category_in,
'post__not_in' => array(get_the_ID()),
'meta_query' => array(
'relation' => 'OR',
array(
'key' => '_Original Post ID',
'compare' => 'NOT EXISTS'
),
array(
'key' => '_Original Post ID',
'value' => 'deleted'
)
),
'paged' => $pnum
);
query_posts($args);
$maxpage = $wp_query->max_num_pages;
}
} else {
$category_in = array();
foreach (get_the_category() as $category) {
array_push($category_in, $category->cat_ID);
}
$args = array(
'category__in' => $category_in,
'post__not_in' => array(get_the_ID()),
'meta_query' => array(
'relation' => 'OR',
array(
'key' => '_Original Post ID',
'compare' => 'NOT EXISTS'
),
array(
'key' => '_Original Post ID',
'value' => 'deleted'
)
),
'paged' => $pnum
);
query_posts($args);
$maxpage = $wp_query->max_num_pages;
}
?>
<?php if (have_posts()) { ?>
<div id="ajax-loader-masonry" class="ajax-loader"></div>
<h3 class="text-center"><?php _e('Related Pins', 'pinc'); ?></h3>
<?php } ?>
<div id="masonry" class="row">
<?php $count_ad = 1; if (have_posts()) : while (have_posts()) : the_post(); ?>
<?php if (of_get_option('frontpage1_ad') == $count_ad && of_get_option('frontpage1_ad_code') != '' && ($pnum == 1 || of_get_option('infinitescroll') == 'disable')) { ?>
<div class="thumb thumb-ad-wrapper">
<div class="thumb-ad">
<?php eval('?>' . of_get_option('frontpage1_ad_code')); ?>
</div>
</div>
<?php } ?>
<?php if (of_get_option('frontpage2_ad') == $count_ad && of_get_option('frontpage2_ad_code') != '' && ($pnum == 1 || of_get_option('infinitescroll') == 'disable')) { ?>
<div class="thumb thumb-ad-wrapper">
<div class="thumb-ad">
<?php eval('?>' . of_get_option('frontpage2_ad_code')); ?>
</div>
</div>
<?php } ?>
<?php if (of_get_option('frontpage3_ad') == $count_ad && of_get_option('frontpage3_ad_code') != '' && ($pnum == 1 || of_get_option('infinitescroll') == 'disable')) { ?>
<div class="thumb thumb-ad-wrapper">
<div class="thumb-ad">
<?php eval('?>' . of_get_option('frontpage3_ad_code')); ?>
</div>
</div>
<?php } ?>
<?php if (of_get_option('frontpage4_ad') == $count_ad && of_get_option('frontpage4_ad_code') != '' && ($pnum == 1 || of_get_option('infinitescroll') == 'disable')) { ?>
<div class="thumb thumb-ad-wrapper">
<div class="thumb-ad">
<?php eval('?>' . of_get_option('frontpage4_ad_code')); ?>
</div>
</div>
<?php } ?>
<?php if (of_get_option('frontpage5_ad') == $count_ad && of_get_option('frontpage5_ad_code') != '' && ($pnum == 1 || of_get_option('infinitescroll') == 'disable')) { ?>
<div class="thumb thumb-ad-wrapper">
<div class="thumb-ad">
<?php eval('?>' . of_get_option('frontpage5_ad_code')); ?>
</div>
</div>
<?php } ?>
<?php
get_template_part('index-masonry-inc');
$count_ad++;
endwhile;
?>
<?php
endif;
wp_reset_query();
?>
</div>
<?php if ($maxpage != 0) { ?>
<div id="navigation">
<ul class="pager">
<?php if ($pnum != 1 && $maxpage >= $pnum) { ?>
<li id="navigation-previous">
<a href="<?php echo get_permalink() . '?pnum=' . ($pnum-1); ?>"><?php _e('« Previous', 'pinc') ?></a>
</li>
<?php } ?>
<?php if ($maxpage != 1 && $maxpage != $pnum) { ?>
<li id="navigation-next">
<a href="<?php echo get_permalink() . '?pnum=' . ($pnum+1); ?>"><?php _e('Next »', 'pinc') ?></a>
</li>
<?php } ?>
</ul>
</div>
<?php } ?>
</div>
</div>