-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsingle.php
executable file
·147 lines (136 loc) · 3.24 KB
/
single.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
<?php get_header(); ?>
<?php
$clcPages = get_clc_nav_pages();
function noPostsExist($txt)
{
?>
<section class="clc-story">
<h2>
Check back soon, we are currently working on stories for this topic.
</h2>
</section>
<?php
}
?>
<main role="main" class="clc-main-style"><div>
<!-- section -->
<section>
<nav class="clc-main-nav">
<header>
Humans of the CLC
</header>
<ul>
<li><a href="<?php echo get_home_url(); ?>">Home</a></li>
<?php
foreach ($clcPages as $clcPage)
{
?>
<li <?php if (get_the_ID() == $clcPage->ID) echo "class='active'"; ?> ><a href="<?php echo get_permalink($clcPage->ID); ?>"><?php echo $clcPage->post_title; ?></a></li>
<?php
}
?>
</ul>
</nav>
</section>
<?php
// $categoryId = get_cat_ID(get_query_var("slug"));
// if ($categoryId === 0)
// {
// noPostsExist(get_query_var("slug"));
// }
// else
// {
// $query = array(
// 'numberposts' => -1,
// 'category' => $categoryId,
// 'orderby' => 'date',
// 'order' => 'DESC',
// 'post_type' => 'post',
// 'suppress_filters' => true
// );
// $story_posts = get_posts( $query );
// $story_posts = randomize_array($story_posts, 1000);
// if (count($story_posts) > 0)
// {
?>
<section class="clc-story">
<?php
global $post;
setup_postdata($post);
$content = get_the_content();
$current_post_id = $post->ID;
$greeting = strpos($content, "<greeting/>");
if ($greeting !== false)
{
$names = explode(" ", $post->post_title);
$content = substr_replace($content, "<h2 class=\"clc-story-greeting\">Meet " . $names[0] . "</h2>", $greeting, 11);
}
?>
<div class="clc-story-main-content">
<?php echo $content;?>
</div>
<div class="clc-story-bottom-content">
<?php
$cats = get_the_category();
$stories = array();
foreach($cats as $c)
{
$cat = get_category( $c );
if ($cat->name != "story")
{
$categoryId = get_cat_ID($cat->name);
$query = array(
'numberposts' => -1,
'category' => $categoryId,
'orderby' => 'date',
'order' => 'DESC',
'post_type' => 'post',
'suppress_filters' => true
);
$stories = array_merge($stories, get_posts( $query ));
}
}
$stories = randomize_array($stories, 1000);
foreach ($stories as $story)
{
if ($story->ID != $current_post_id)
{
setup_postdata($story);
$content = get_the_content();
//remove <a>
$keepLooping = true;
while ($keepLooping)
{
$tagLocStart = strpos($content, "<a ");
if ($tagLocStart === false)
{
$keepLooping = false;
}
else
{
$tagLocEnd = strpos($content, ">", $tagLocStart) + 1;
$content = substr_replace($content,"",$tagLocStart, $tagLocEnd - $tagLocStart);
$tagLocStart = strpos($content, "</a>");
$content = substr_replace($content,"",$tagLocStart, 4);
}
}
$div_click = "onclick=\"viewStory('" . get_permalink($story) . "')\"";
?>
<div class="clc-story-bottom-stories" <?php echo $div_click; ?>>
<?php echo $content;?><br/>
</div>
<?php
}
}
?>
</div>
</section>
<?php
// }
// else
// {
// noPostsExist(get_query_var("slug"));
// }
// }
?>
</div></main>